在C++中内联成员函数与非内联成员函数的可以分为两种情况:1.如果成员函数的声明和定义是在一起的,那么无论有没有写inline这个成员函数都是内联的,如下:using namespace std;class test{public: void fuc() { cout using namespac....
分类:
编程语言 时间:
2014-11-08 11:42:29
阅读次数:
258
#include int main(){ //std::cout > v1 >> v2; //std::cin >> v1; //std::cin >> v2; std::cout >"输入操作数,输入操作符返回其左操作数作为结果;__________________________________...
分类:
编程语言 时间:
2014-11-08 02:00:44
阅读次数:
285
今天看了篇介绍condition_variable的文章。于是copy例子到IDE下运行看看,小改了个地方,就出现了让我百思不得姐的结果。 程序如下: #include // std::cout #include // std::thread #include // std::mutex, st...
分类:
其他好文 时间:
2014-11-08 00:58:21
阅读次数:
269
C++伪函数:
所谓的伪函数,就是说它不是一个真正的函数,而是一个类或者说是一个结构体。
#include
void say_hello(){
std::cout << "hello world !" << std::endl;
}
class Hello{
public:
void operator () (){
std::c...
分类:
编程语言 时间:
2014-11-07 14:51:42
阅读次数:
177
1.下面这段代码,输出时多少?1 int _tmain(int argc, _TCHAR* argv[])2 {3 for(char a = 0; a < 255; a++)4 {5 cout << (int(a))<< endl;6 }7 syste...
分类:
其他好文 时间:
2014-11-07 11:01:22
阅读次数:
198
需要头文件#include queue q;q.push(12);while(!q.empty() ){cout q; //默认按照从大到小排序q.push(1);q.push(2);while(!q.empty() ){cout , greater > q; //按照从小到大的顺序q.push.....
分类:
其他好文 时间:
2014-11-07 00:55:54
阅读次数:
132
double fu,mo;
fu=0;
mo=0;
int i;
for(i=1;i<31;i++)
{
fu+=100000;
mo+=0.01;
mo*=2;
cout<<"第"<<i<<"天富earn"<<fu<<" ";
cout<<"陌earn"<<mo<<endl;
}
cout<<"富人得到的钱:...
分类:
其他好文 时间:
2014-11-05 23:13:59
阅读次数:
150
刚开始接触C++时,指针和const之间的关系有点混乱,现在总结如下: 一、指向const变量的指针 #include
void main()
{ const int *p=NULL; const int a=10; p=&a; cout
void main()
{ int a=10; int b=...
分类:
编程语言 时间:
2014-11-05 22:43:29
阅读次数:
292
比较简单的问题:#include#includeusing namespace std;int main(){ int lengthOfLastWord(const char *s); char a[20]; cin.getline(a,20); cout << length...
分类:
其他好文 时间:
2014-11-05 21:11:57
阅读次数:
172
警告:此题不可以使用cout进行输出,只能用printf,否则RE!亲测!!
题目大意:给定一棵树,每个点有一个点权,提供四种操作:
1.删除两点之间的连边 不存在边则无视
2.在两点之前连接一条边 两点已经联通则无视
3.在两点之间的路径上所有点的点权加上一个数 两点不连通则无视
4.询问两点之间路径上任选两点路径上的点权和的期望值
前三个操作都很基础 但是第四个东西……这啥玩应这是...
分类:
其他好文 时间:
2014-11-05 19:53:09
阅读次数:
158