如何製作鏈接列表的矢量?製作鏈接列表的矢量?
比如我有屬性的結構(該鏈接列表)定義如下:
typedef struct property {
string info;
property* implication;
} property;
然後,我有一個類對象:
class objects {
private:
vector<property> *traits;
public:
void giveProperty(property *x) {
traits.push_back(&x);
}
};
,我想什麼在概念上是給一個對象某些屬性,每個屬性都有一系列的含義(這是鏈表),我可以在以後使用。但我得到的錯誤:
request for member 'push_back' in '((objects*)this)->objects::traits', which is of non-class type 'std::vector >*'
我有麻煩得到這個工作。對不起,如果這不清楚,如果你有問題,我會嘗試澄清自己。
爲什麼'traits'是一個指針? – GManNickG 2011-03-19 20:39:12