爲什麼我得到這個錯誤?我很茫然...C++錯誤:'v'中成員'push_back'的請求
錯誤:請求用於v
構件push_back
,其是非類類型std::vector<Leaf, std::allocator<Leaf> >*
class Leaf
{
public:
// Variables
std::string *name;
// Methods
Leaf(){}
Leaf(std::string *s)
{
name = s;
}
};
class Branch
{
public:
// Variables
Branch::Branch *parent;
Branch::Branch *child;
std::vector<Leaf> *children;
std::string *name;
// Methods
Branch(std::string *s)
{
children = new std::vector<Leaf>;
name = s;
}
};
class Tree
{
public:
// Variables
Branch::Branch *current;
// Methods
Tree(string *name)
{
current = new Branch::Branch(name);
}
void addBranch(Branch::Branch *newBranch)
{
this->current->child = newBranch;
newBranch->parent = this->current;
}
void addLeaf(Leaf::Leaf *leaf)
{
std::vector<Leaf> *v = this->current->children;
v.push_back(leaf);
}
};