摘要:
Student& st = CollegeStudent("eatman",22);其中CollegeStudent是Student的子类g++编译报错:main.cc: In function ‘int main()’:main.cc:8: error: invalid initialization of non-const reference of type ‘Student&’ from a temporary of type ‘CollegeStudent’临时对象是const的。所以const Student& st = CollegeSt 阅读全文
posted @ 2012-01-31 16:33
sharpstill
阅读(626)
评论(1)
推荐(0)
摘要:
C++泛型模板类使用小结:泛型类可以让源代码“实现”文件cc 和 头文件分离,书写规则只要遵循如下所示:文件一:Test.h的泛型模版类的头文件#include <iostream>#ifndef TEST_H#define TEST_Htemplate <typename T>class Test{ private: T t; public: void echo(void); //这个方法就一个功能,把私有的T类型成员变量打印出来 Test(T);};#include "Test.cc" //注意这里,引入了他的"实现文件",代 阅读全文
posted @ 2012-01-31 14:12
sharpstill
阅读(1587)
评论(0)
推荐(0)
浙公网安备 33010602011771号