Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我只是想知道我是否可以做这样的事情:
class apple { public: "constructor and public method in here" private: vector<*apple> allApple; }
这段代码好吗?
您可能是指指向同一类型的指针向量,
vector<apple*> allApple;
在这种情况下,是的,您可以,尽管如果智能指针指向动态分配的对象,您可能更愿意保留这些指针。