上一页 1 ··· 5 6 7 8 9 10 11 12 下一页
摘要: C++语言: Codee#2574401 /*02 对象切片03 此处为传值 注意与传地址相比较04 */05 #include <iostream>06 #include <string>07 using namespace std;08 09 class Pet10 {11 string pname;12 public:13 Pet(const string& name)14 : pname(name)15 {}16 virtual string name() const17 {18 return pname;19 }20 virtual string de 阅读全文
posted @ 2012-03-08 10:46 strorehouse 阅读(202) 评论(0) 推荐(0) 编辑
摘要: C++语言: Codee#2574201 #include <iostream>02 #include <cstdio>03 using namespace std;04 05 class NotEmpty06 {07 08 };09 10 int main()11 {12 cout<<sizeof(NotEmpty)<<endl;13 return 0;14 }15 16 /*17 118 19 Process returned 0 (0x0) execution time : 0.027 s20 Press any key to contin 阅读全文
posted @ 2012-03-08 09:30 strorehouse 阅读(110) 评论(0) 推荐(0) 编辑
摘要: C++语言: Codee#2574101 /*02 私有继承成员的公有化03 */04 class Pet05 {06 public:07 char eat() const08 {09 return 'a';10 }11 int speak() const12 {13 return 2;14 }15 float sleep() const16 {17 return 3.0;18 }19 float sleep(int) const20 {21 return 4.0;22 }23 };24 25 class Goldfish: Pet //private in... 阅读全文
posted @ 2012-03-07 20:33 strorehouse 阅读(183) 评论(0) 推荐(0) 编辑
摘要: C++语言: Codee#2573601 /*02 构造函数设为私有03 +04 类自身的静态数据成员放到类的内部05 */06 07 #include <iostream>08 using namespace std;09 class Egg10 {11 static Egg e; // it's so strange!12 int i;13 Egg(int ii)14 : i(ii)15 {}16 Egg(const Egg&);17 public:18 static Egg* instance()19 {20 return... 阅读全文
posted @ 2012-03-06 15:32 strorehouse 阅读(144) 评论(0) 推荐(0) 编辑
摘要: C++语言: Codee#2573401 /*02 枚举值不占用对象空间,编译期间得到枚举值03 */04 05 #include <iostream>06 using namespace std;07 08 class Bunch09 {10 enum11 {12 size = 100013 };14 int i[size];15 };16 17 int main()18 {19 cout << "sizeof(bunch) =" << sizeof(Bunch)20 << ",sizeof(i[1000]) = 阅读全文
posted @ 2012-03-06 10:54 strorehouse 阅读(297) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2012-03-06 10:00 strorehouse 阅读(95) 评论(0) 推荐(0) 编辑
摘要: C++语言: Codee#2573001 #include <>iostream>02 using namespace std;03 04 union U05 {06 private:07 int i;08 float f;09 public:10 U(int a);11 U(float b);12 ~U();13 int read_int();14 float read_float();15 };16 17 U::U(int a)18 {19 i = a;20 }21 22 U::U(float b)23 {24 f = b;25 }26 27 U::~U()28 {29 阅读全文
posted @ 2012-03-05 20:43 strorehouse 阅读(167) 评论(0) 推荐(0) 编辑
摘要: C++语言: Codee#2572801 /* 02 table-driven example from <<thinking in cpp>>03 */04 05 06 #include <iostream>07 using namespace std;08 09 #define DF(N) void N(){\10 cout << "function"#N " called..."<<endl;}11 12 DF(a);13 DF(b);14 DF(c);15 DF(d);16 17 voi 阅读全文
posted @ 2012-03-05 10:24 strorehouse 阅读(148) 评论(0) 推荐(0) 编辑
摘要: C++语言: Codee#2572001 /*02 +++++++++++++++++++++++++++++++++++++++03 author: chm04 +++++++++++++++++++++++++++++++++++++++05 */06 07 #include <map>08 #include <set>09 #include <list>10 #include <queue>11 #include <cmath>12 #include <stack>13 #include <bitset> 阅读全文
posted @ 2012-03-03 16:31 strorehouse 阅读(231) 评论(0) 推荐(0) 编辑
摘要: C++语言: Codee#2571901 /*02 +++++++++++++++++++++++++++++++++++++++03 author: chm04 +++++++++++++++++++++++++++++++++++++++05 */06 07 #include <map>08 #include <set>09 #include <list>10 #include <queue>11 #include <cmath>12 #include <stack>13 #include <bitset> 阅读全文
posted @ 2012-03-03 15:52 strorehouse 阅读(233) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 下一页