What are the pros and cons of each approach?

Excuse me,my English is poor.
Compare two kinds of class design.
1.
1
2
3
4
5
6
class A
{
public:
    //Ingnore other member and implement
    vector<A*> m_vSubA; 
};


2.
1
2
3
4
5
6
class B
{
public:
 //Ingnore other member and implement
};
vector<B*> m_vecB;
Last edited on
It's a question of using the right design for the right problem. Does it make sense conceptually for an object of type A to contain a collection of other objects of the same type? That will depend on what A actually represents, and what relationships between objects you want to model.
Topic archived. No new replies allowed.