C++ template class inheritance -


#include <iostream> using namespace std;  template <class t> class c1 { public:     int n;     c1(int a)     {         n=a;     }     t mat[50][50];     void readmat()     {         int i,j;         for(i=1; i<=n; i++)for(j=1; j<=n; j++)cin>>mat[i][j];     }     void showmat()     {         int i,j;         for(i=1; i<=n; i++)         {             cout<<endl;             for(j=1; j<=n; j++)cout<<mat[i][j]<<" ";         }     } };  template <class t> class c2: public c1<t> {     c2(int a): c1(a) {};  }; 

whenever run it, error:

in constructor c2::c2(int)':

error: class 'c2' not have field named 'c1'

if explain me did wrong, appreciate it.

you should add template parameter base class

template <class t> class c2: public c1<t> {     c2(int a): c1<t>(a) {};  }; 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -