当前位置: 移动技术网 > IT编程>开发语言>C/C++ > 保留一个未解决的问题

保留一个未解决的问题

2019年04月12日  | 移动技术网IT编程  | 我要评论

枪炮天使,都市炎黄,都市歌丽姿

//
//  main.cpp
//  testvoidmain
//
//  created by mac on 2019/4/11.
//  copyright © 2019年 mac. all rights reserved.
//  1.只有成员函数才能有const限定符
//  2.脑袋怎么总是混乱
//  3.在类内部定义指向函数的指针有点蠢?

#include <iostream>

using namespace std;

template <class gentype>
class classf{
public:
    classf(){
        
    }
    ~classf(){}
    gentype fun1(gentype &);
    gentype (classf:: *p)(gentype &)=&classf::fun1;

};

template<class gentype>
gentype classf<gentype>::fun1(gentype &a){
    return a;
}

int main(int argc, const char * argv[]) {
    
    
    classf<int> cf,*q=&cf;
    
    int a=3;
    cout<<cf.fun1(a)<<endl;
    
    cout<<(cf.*p(a));
    
    cout << "hello, world!\n";
    return 0;
}

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网