随笔分类 -  C/C++

摘要:class Number { int number; public: explicit Number(int n){number = n;} operator int() //注意一定不能声明返回值 { return number; } }; int main () { ... 阅读全文
posted @ 2011-11-10 13:11 Fan Zhang 阅读(172) 评论(0) 推荐(0)
摘要:-------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------运行结果:1 2 3 ... 阅读全文
posted @ 2010-03-24 15:28 Fan Zhang 阅读(290) 评论(0) 推荐(0)
摘要:string mystr="100"; float price=200; stringstream(mystr) >> price; 阅读全文
posted @ 2009-10-23 15:18 Fan Zhang 阅读(178) 评论(0) 推荐(0)
摘要:ifstream in("STLExtension.h",ios::ate); if (in.is_open()) { cout << "file length is " << in.tellg() << endl; } 阅读全文
posted @ 2009-10-23 14:52 Fan Zhang 阅读(216) 评论(0) 推荐(0)
摘要:#include <iostream>using namespace std;class Base {public: Base() { cout << "In Base" << endl; cout << "Virtual Pointer = " << (int*)this << endl; cout << "Ad... 阅读全文
posted @ 2009-09-11 16:18 Fan Zhang 阅读(397) 评论(0) 推荐(0)
摘要:malloccalloc,初始化每个元素都为0realloc 重新分配新的地址,将旧地址拷贝到新地址里 阅读全文
posted @ 2009-07-07 15:35 Fan Zhang 阅读(192) 评论(0) 推荐(0)
摘要:http://melkov.narod.ru/misc/stl-fix/ 阅读全文
posted @ 2009-06-24 14:41 Fan Zhang 阅读(205) 评论(0) 推荐(0)