Inheriting from a template class in c++

前端 未结 6 2134
遥遥无期
遥遥无期 2020-12-12 10:00

Let\'s say we have a template class Area, which has a member variable T area, a T getArea() and a void setArea(T) member

6条回答
  •  星月不相逢
    2020-12-12 10:26

    #include
    
    using namespace std;
    
    template 
    class base {
    protected:
        t a;
    public:
        base(t aa){
            a = aa;
            cout<<"base "< 
    class derived: public base{
        public:
            derived(t a): base(a) {
            }
            //Here is the method in derived class 
        void sampleMethod() {
            cout<<"In sample Method"< q(1);
        // calling the methods
        q.sampleMethod();
    }
    

提交回复
热议问题