C++ template模版长期举例总结

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xin_y/article/details/86221999

example_1

#include<iostream>
using namespace std;
#include<stdio.h>

template<typename T>
class ID
{
    public:
    ID() : a(0) {}
    T getA() { return a;}
    void setA(T a_) { a = a_; }

    private:
        T a;
};

template<typename T>
class A : public T
{
};

int main()
{
    ID<int> id;

    A<ID<int> > ids;

    printf("%d\n", ids.getA());
    return 0;
}

猜你喜欢

转载自blog.csdn.net/xin_y/article/details/86221999