Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/140.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ c++;如何使用类模板创建对象_C++_Templates_Inheritance - Fatal编程技术网

C++ c++;如何使用类模板创建对象

C++ c++;如何使用类模板创建对象,c++,templates,inheritance,C++,Templates,Inheritance,我有以下代码 Main.cpp: Warehouse<Base<int>> arm(1, 1, 1, 1); arm.createSubBase(1,1,1); private: vector<Base<T>*> whouse; public : void createSubBase(int, int, int); template <class T> void Warehouse<T>::createSubBas

我有以下代码

Main.cpp:

Warehouse<Base<int>> arm(1, 1, 1, 1);
arm.createSubBase(1,1,1);
private:
 vector<Base<T>*> whouse;
public :
 void createSubBase(int, int, int);

template <class T> 
void Warehouse<T>::createSubBase(int,int,int) {
  Base<T>* dN = new SubBase<T>(int,int,int,int); ***<-ERROR MESSAGE:" in file included from"***
     whouse.push_back(dN);
}
template <class T>
class Base {
private:
 int I,a,b,c;
public :
  Base(int,int,int,int);
}

template <class T>
Base<T>::Base(int i, int a, int b, int c) {
    this -> I = i;
    this -> a= a;
    this -> b= b;
    this -> c = c;
}
template <class T>
class SubBase: public Base<T> {
public:
  SubBase(int, int, int,int);
}
template <class T>
SubBase<T>::SubBase(int, int, int , int) : Depositos<T>(int,int,int,int) {...}
仓库臂(1,1,1,1);
臂底基层(1,1,1);
仓库。h:

Warehouse<Base<int>> arm(1, 1, 1, 1);
arm.createSubBase(1,1,1);
private:
 vector<Base<T>*> whouse;
public :
 void createSubBase(int, int, int);

template <class T> 
void Warehouse<T>::createSubBase(int,int,int) {
  Base<T>* dN = new SubBase<T>(int,int,int,int); ***<-ERROR MESSAGE:" in file included from"***
     whouse.push_back(dN);
}
template <class T>
class Base {
private:
 int I,a,b,c;
public :
  Base(int,int,int,int);
}

template <class T>
Base<T>::Base(int i, int a, int b, int c) {
    this -> I = i;
    this -> a= a;
    this -> b= b;
    this -> c = c;
}
template <class T>
class SubBase: public Base<T> {
public:
  SubBase(int, int, int,int);
}
template <class T>
SubBase<T>::SubBase(int, int, int , int) : Depositos<T>(int,int,int,int) {...}
private:
病媒whouse;
公众:
void createSubBase(int,int,int);
模板
无效仓库::createSubBase(int,int,int){
基本*dN=新子基(int,int,int,int);***I=I;
这->a=a;
这->b=b;
这个->c=c;
}
底基层。h:

Warehouse<Base<int>> arm(1, 1, 1, 1);
arm.createSubBase(1,1,1);
private:
 vector<Base<T>*> whouse;
public :
 void createSubBase(int, int, int);

template <class T> 
void Warehouse<T>::createSubBase(int,int,int) {
  Base<T>* dN = new SubBase<T>(int,int,int,int); ***<-ERROR MESSAGE:" in file included from"***
     whouse.push_back(dN);
}
template <class T>
class Base {
private:
 int I,a,b,c;
public :
  Base(int,int,int,int);
}

template <class T>
Base<T>::Base(int i, int a, int b, int c) {
    this -> I = i;
    this -> a= a;
    this -> b= b;
    this -> c = c;
}
template <class T>
class SubBase: public Base<T> {
public:
  SubBase(int, int, int,int);
}
template <class T>
SubBase<T>::SubBase(int, int, int , int) : Depositos<T>(int,int,int,int) {...}
模板
类别底基层:公共基层{
公众:
子基(int,int,int,int);
}
模板
子基::子基(int,int,int,int):存款(int,int,int,int){…}

有人知道我为什么会收到这个错误消息吗?我不明白为什么不让我创建
Base*b=新的子基(int,int,int)

函数参数必须是给出参数值的表达式,而不是像
int
这样的类型名称。因此,有问题的路线应该是

Base<T>* dN = new SubBase<T>(a,b,c,d);
您还缺少
在类定义之后

修复这些错误后,代码将为我编译: