Linux下编译C++11代码的方法

g++ -std=c++11 helloworld.cpp -o helloworld

#include <iostream>
using namespace std;
class A{
    public:
        static int get(void){
            return 100;
        }
};

class B{
    public:
        static const char* get(void){
            return "http://salman.net/cplus/";
        }
};

template <typename T>
void func(void){
    auto val=T::get();
    cout<<val<<endl;
}

int main(void){
    func<A>();
    func<B>();

    return 0;
}
100
http://salman.net/cplus/

猜你喜欢

转载自blog.csdn.net/aa804738534/article/details/112978893