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.

Recommended Answers

All 2 Replies

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.

commented: Nice. +15

Thank you very much, it helped.

Best Regards,
Praveen

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.