快乐大本营20090221,偷逃上万元通行费,常州无痛人流多少钱
// // main.cpp // friendfunction // 1. 静态成员变量需要在类中声明,在类外定义。 // 2. 友元函数相当于成员函数,可以访问私有变量,破坏信息的隐藏性。 // 3. 模版类的的静态成员变量的定义与声明。 // created by mac on 2019/4/8. // copyright © 2019年 mac. all rights reserved. // #include <iostream> using namespace std; //模版类中嵌套模版函数 //模版类 template <class gentype> class genclass { public: genclass(gentype a){ n=a; } ~genclass(){} //模版函数 template <class gentype> gentype f(gentype n){ return n; }; friend int g();//友元函数 private: static gentype n;//静态成员变量 默认初始化为0 double a=1.5; }; template <class gentype>gentype genclass<gentype>::n; int g(){ return genclass<int>::n; } int main(int argc, const char * argv[]) { genclass<int> object1(3),*p=&object1; cout<<p->f<int>(3)<<endl; cout<<g()<<endl; return 0; }
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
如何在没有core文件的情况下用dmesg+addr2line定位段错误
用QT制作3D点云显示器——QtDataVisualization
网友评论