0
class Data {
    string name;
    string ID;
public:
    Data(){cout<<"Data"<<endl;}
};
class info{
    string name;
    string ID;
public:
    info(){cout<<"info"<<endl;}
};

Two classes defined above. Now I want to create a vector of type

std::vector<Data obj1, info obj2> container;

further I want to use the vector features using the vector container.
How i can create a vector container having two class objects ?
please help me.

2
Contributors
2
Replies
16
Views
1 Year
Discussion Span
Last Post by prahesh
1

Not sure what you are trying to do, but I feel confident it isn't this:

std::vector<Data obj1, info obj2> container;

Perhaps you want to make a third class made up of the other two classes?

class ThirdClass
{
    Data obj1;
    info obj2;
};
vector <ThirdClass> container;

You may need to expand on what your goal is.

Votes + Comments
Nice.
0

Thank you very much, it helped.

Best Regards,
Praveen

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.