1.类中的静态变量成员的声明:
//myclass.h
class myclass{
static int icCount;//put in the class
}
初始化:
//myclass_implement.cpp
#include"myclass.h"
int myclass::icCount=0;//put in .cpp file but out of any function
2.模版使用
//myclass.h
template <class T,class TT>
class a{
public:
a(int i,const T t,const TT tt);
};
//main.cpp
#include"myclass.h"
int main()
{
a<int,int> dd(1,2,3);
a<int,int> *p;
p= new a<int,int>(1,2,3.5);
return 1;
}
template <class T,class TT>
a<T,TT>::a(int i,const T t,const TT tt)
{}
C++小段子
最新推荐文章于 2021-10-20 21:11:17 发布