我很想知道矢量类型定义中“ref”的含义是什么。C++ Vector关键字“ref”
我新的C++和上一段代码,我剥离出来学习,我发现
vector<ref<StupidBug> > bugs;
其中“StupidBug”是一类。
它不会在GCC编译/ C++ 11,因为“模板参数‘>’是无效的”,但移动“>”的左侧,接近前一个仍然给出了同样的错误
这使我感到困惑,我不知道错误在哪里。
这段代码已经过了几年了,可能会写错吗? “ref”属于C++吗?
这是一个多版本吗?或模板?
的背景资料:
全是有关插入和移动网格“错误”和矢量持有错误的数量,并把它们在一定的位置。
这里的代码,首先我有一个Stupidbug类
class StupidBug
{
public:
int x();
int y();
// member initialization list
StupidBug(GraphID_t i=-1): cellID(i) {}
void move();
void draw(const eco_string& canvas);
};
并与“裁判”的载体是另一个类:
class Model: public Space
{
public:
urand u; //random generator for positions
int tstep; //timestep - updated each time moveBugs is called
int scale; //no. pixels used to represent bugs
vector<ref<StupidBug> > bugs;
addBugs(int nBugs);
void addBugs();
void moveBugs();
void draw(TCL_args args);
};
感谢您的回答!
这不是关键字。它是一个函数模板的名称。 – EJP
根据@StoryTeller的评论,您可能正在寻找std :: vector> –
SVictor
@EJP你是完全错误的。它是用户定义的智能指针。 –