模板矢量,不完整类型错误 [英] template vector, incomplete type error

查看:79
本文介绍了模板矢量,不完整类型错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在迁移一些std :: vectors而不是使用模板,但我在结构声明中得到了

不完整的类型错误。


#include< vector>


template< typename T>

class Vec:public std :: vector< T {

public:

Vec():Vec< T>(){}

Vec(int s):std :: vector< ; T>(s){}

T& operator [](int i){return at(i); }

const T& operator [](int i)const {return at(i); }

};

typedef Vec< doublevecdbl;

typedef Vec< vecdblmatdbl;

#include" matvec .h"

//就在上面


typedef vecdbl memvec;


struct felt

{

...

memvec m; //< - 不完整类型错误

Hi,
I am migrating some std::vectors to use a template instead, but I get
an incomplete type error in a struct declaration.

#include <vector>

template < typename T >
class Vec : public std::vector< T {
public:
Vec():Vec<T>() { }
Vec( int s ) : std::vector<T>(s) { }
T& operator[](int i) { return at(i); }
const T& operator[](int i ) const { return at(i); }
};
typedef Vec<doublevecdbl;
typedef Vec<vecdblmatdbl;
#include "matvec.h"
// that is it above

typedef vecdbl memvec;

struct felt
{
...
memvec m; // <- incomplete type error

推荐答案

文章< 11 ************ **********@c28g2000cwb.googlegroups .com> ;,

< im ***** @ hotmail.co.ukwrote:
In article <11**********************@c28g2000cwb.googlegroups .com>,
<im*****@hotmail.co.ukwrote:

>
我正在迁移一些std :: vectors而不是使用模板,但我在结构声明中得到了一个不完整的类型错误。

#include< vector>

模板< typename T>
类Vec:public std :: vector< T {
public:

Vec():Vec< T>(){}

Vec(int s):std :: vector< T>( s){}

T& operator [](int i){return at(i); }

const T& operator [](int i)const {return at(i); }
};

typedef Vec< doublevecdbl;
typedef Vec< vecdblmatdbl;

#include" matvec.h"
/ /就是它上面

typedef vecdbl memvec;

结构感觉
{
..
memvec m; //< - 不完整类型错误
>Hi,
I am migrating some std::vectors to use a template instead, but I get
an incomplete type error in a struct declaration.

#include <vector>

template < typename T >
class Vec : public std::vector< T {
public:
Vec():Vec<T>() { }
Vec( int s ) : std::vector<T>(s) { }
T& operator[](int i) { return at(i); }
const T& operator[](int i ) const { return at(i); }
};
typedef Vec<doublevecdbl;
typedef Vec<vecdblmatdbl;
#include "matvec.h"
// that is it above

typedef vecdbl memvec;

struct felt
{
..
memvec m; // <- incomplete type error



我不明白Vec():Vec< T>(),可能你是编译器
因为这个问题,
最终没有成为Vec< Tincomplete课程



-

Greg Comeau / 20年的Comeauity! Intel Mac Port现在为alpha!

Comeau C / C ++ ONLINE == http://www.comeaucomputing.com/tryitout

世界级编译器:令人惊叹的C ++,惊人的C99,很棒的C90。

Comeau C / C ++与Dinkumware你的图书馆......你试过吗?

I don''t understand Vec():Vec<T>() and probably you''re compiler
doesn''t either eventually makeing Vec<Tincomplete classes
because of that problem.
--
Greg Comeau / 20 years of Comeauity! Intel Mac Port now in alpha!
Comeau C/C++ ONLINE == http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware''s Libraries... Have you tried it?


在文章< ef ********** @ panix1.panix.com>中,

Greg Comeau< co **** @ comeaucomputing.comwrote:
In article <ef**********@panix1.panix.com>,
Greg Comeau <co****@comeaucomputing.comwrote:

>文章< 11 ***** *****************@c28g2000cwb.googlegroups .com> ;,

< im ***** @ hotmail.co.ukwrote:
>In article <11**********************@c28g2000cwb.googlegroups .com>,
<im*****@hotmail.co.ukwrote:

>>
我正在迁移一些std :: vectors而不是使用模板,但是我得到了一个不完整的类型错误结构声明。

#include< vector>

模板< typename T>
类Vec:public std :: vector< T {
public:
Vec():Vec< T>(){}
Vec(int s):std :: vector< T>(s){}
T&安培; operator [](int i){return at(i); }
const T& operator [](int i)const {return at(i); }
};

typedef Vec< doublevecdbl;
typedef Vec< vecdblmatdbl;

#include" matvec.h"
/ /就是它上面

typedef vecdbl memvec;

结构感觉
{
..
memvec m; //< - 不完整类型错误
>>Hi,
I am migrating some std::vectors to use a template instead, but I get
an incomplete type error in a struct declaration.

#include <vector>

template < typename T >
class Vec : public std::vector< T {
public:
Vec():Vec<T>() { }
Vec( int s ) : std::vector<T>(s) { }
T& operator[](int i) { return at(i); }
const T& operator[](int i ) const { return at(i); }
};
typedef Vec<doublevecdbl;
typedef Vec<vecdblmatdbl;
#include "matvec.h"
// that is it above

typedef vecdbl memvec;

struct felt
{
..
memvec m; // <- incomplete type error


我不明白Vec():Vec< T>(),可能你是编译器
不会''由于这个问题,最终要么成为Vec< Tincomplete classes


I don''t understand Vec():Vec<T>() and probably you''re compiler
doesn''t either eventually makeing Vec<Tincomplete classes
because of that problem.



另外在另一个方面:std :: vector未被写为

派生自。

-

Greg Comeau / 20年的Comeauity! Intel Mac Port现在为alpha!

Comeau C / C ++ ONLINE == http://www.comeaucomputing.com/tryitout

世界级编译器:令人惊叹的C ++,惊人的C99,很棒的C90。

Comeau C / C ++与Dinkumware你的图书馆......你试过吗?

Also on a different aspect: std::vector was not written to be
derived from.
--
Greg Comeau / 20 years of Comeauity! Intel Mac Port now in alpha!
Comeau C/C++ ONLINE == http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware''s Libraries... Have you tried it?


im * **** @ hotmail.co.uk 写道:
im*****@hotmail.co.uk wrote:

#include< vector>


模板< typename T>

class Vec:public std :: vector< T {

public:

Vec():Vec< T>(){}
#include <vector>

template < typename T >
class Vec : public std::vector< T {
public:
Vec():Vec<T>() { }



Vec( ):std :: vector< T>(){}

Vec() : std::vector<T>() {}


Vec(int s):std :: vector< T>(s){}

T& operator [](int i){return at(i); }
Vec( int s ) : std::vector<T>(s) { }
T& operator[](int i) { return at(i); }



& operator [](int i){return this-> at(i); }

& operator[](int i) { return this->at(i); }


const T& operator [](int i)const {return at(i); }
const T& operator[](int i ) const { return at(i); }



const T& operator [](int i)const {return this-> at(i); }

const T& operator[](int i ) const { return this->at(i); }


};


typedef Vec< doublevecdbl;

typedef Vec< vecdblmatdbl;


#include" matvec.h"

//就在上面


typedef vecdbl memvec;


结构感觉

{

..

memvec m; * //< - 不完整类型错误
};
typedef Vec<doublevecdbl;
typedef Vec<vecdblmatdbl;
#include "matvec.h"
// that is it above

typedef vecdbl memvec;

struct felt
{
..
memvec m; *// <- incomplete type error



最佳


Kai-Uwe Bux


Best

Kai-Uwe Bux


这篇关于模板矢量,不完整类型错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆