模板定义有错?template class Matrix{private:vector matrix;typedef vector::iterator itor; //这一句有错typedef vector::iterator iter; 13 C:\Documents and Settings\Administrator\My Documents\矩阵.cpp type `std::vector' is not derived from ty

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/10 20:36:41
模板定义有错?template class Matrix{private:vector matrix;typedef vector::iterator itor; //这一句有错typedef vector::iterator iter; 13 C:\Documents and Settings\Administrator\My Documents\矩阵.cpp type `std::vector' is not derived from ty

模板定义有错?template class Matrix{private:vector matrix;typedef vector::iterator itor; //这一句有错typedef vector::iterator iter; 13 C:\Documents and Settings\Administrator\My Documents\矩阵.cpp type `std::vector' is not derived from ty
模板定义有错?
template class Matrix{
private:
vector matrix;
typedef vector::iterator itor; //这一句有错
typedef vector::iterator iter;
13 C:\Documents and Settings\Administrator\My Documents\矩阵.cpp type `std::vector' is not derived from type `Matrix'
13 C:\Documents and Settings\Administrator\My Documents\矩阵.cpp ISO C++ forbids declaration of `iterator' with no type

模板定义有错?template class Matrix{private:vector matrix;typedef vector::iterator itor; //这一句有错typedef vector::iterator iter; 13 C:\Documents and Settings\Administrator\My Documents\矩阵.cpp type `std::vector' is not derived from ty
typedef不支持这样的定义,但是宏支持,如下:
#include
using namespace std;
int *GetAdd(int *a,long *b)
{
*a += *b;
return a;
}
template
class Matrix
{
private:
vector matrix;
typedef int *(*pMyFunc)(int *,long*);//定义函数指针类型
typedef vector myTvector;//定义向量T类型
#define itor vector::iterator//定义向量T类型的向量的指针
private:
Matrix()
{
itor kk = matrix.begin();//使用向量T类型的向量的指针
pMyFunc = GetAdd;//函数指针
}
};
void main(void)
{
}