123.static静态函数与类模板

 1 #include <iostream>
 2 using namespace std;
 3 
 4 //静态函数没有this指针,无需创建对象就可以直接调用
 5 
 6 template<class T>
 7 class myclass
 8 {
 9 public:
10     void go1()
11     {
12 
13     }
14     static void go2()
15     {
16 
17     }
18 };
19 
20 void main()
21 {
22     auto fun1 = &myclass<int>::go1;
23     auto fun2 = &myclass<int>::go2;
24 
25     //成员函数与静态函数最大区别就是函数指针类型不一样,静态函数没有this指针
26     cout << typeid(fun1).name() << endl;
27     cout << typeid(fun2).name() << endl;
28 
29     cin.get();
30 }
原文地址:https://www.cnblogs.com/xiaochi/p/8618630.html