文章分类 -  Standard C++

摘要:#include #include #include #include using namespace std;int main(){ string str_file; ifstream infile("TEST"); int wc = 0; while ( infile >> str_file )... 阅读全文
posted @ 2014-05-10 08:14 刀刀 阅读(568) 评论(0) 推荐(0)
摘要:组合就是一个类的对象作为另一个类的成员对象 比如 //class X; class Y { private: X x; } 注意: 由于类Y中有类X的对象x,为了保证在初始化Y的对象之前正确初始化X中的x,C++中提供了初始化列表的方法可以显式的调用x的构造函数。 //x.h class X { private: int i; public: X(int val) { i ... 阅读全文
posted @ 2008-05-01 17:35 刀刀 阅读(192) 评论(0) 推荐(0)
摘要:1.局部静态变量(对象) ///local_static.cpp #include using namespace std; int get_next() { static int i = 0; //Note return i++; } int main() { cout<<get_next()<<endl; cout<<get_next()<<endl; ... 阅读全文
posted @ 2008-04-05 18:12 刀刀 阅读(927) 评论(0) 推荐(0)
摘要:首先,const是由C++采用并加进标准C中的。区别一:在C中,编译器对待const如同变量一样,只不过带有一个特殊的标记,意思是“不要改变我”。所以,在C中不可以用const变量作为数组维数。而在C++中,const变量在编译时刻就常量化了。区别二:在C中,const变量的连接属性是外部的,而C++中,其属性是内部的。 阅读全文
posted @ 2006-11-20 14:16 刀刀 阅读(404) 评论(0) 推荐(0)
摘要:下载BP.rar 阅读全文
posted @ 2006-01-16 22:48 刀刀 阅读(372) 评论(0) 推荐(0)
摘要:C风格字符串的表示和使用方法 C风格字符串的表示有两种 char *a = "hello!"; char b[] = "hello!"; 这两种的效果是一样的,在内存中的表示都是:a代表字符串的起始地址,而字符串以字符串结束标志'\0' 结束,因此实际占的位数比真实位数多一位。在使用时,由于b是const char* 类型的,所以只能使用索引... 阅读全文
posted @ 2005-04-28 01:49 刀刀 阅读(1736) 评论(0) 推荐(0)