Vector of objects
Posted
by Paul
on Stack Overflow
See other posts from Stack Overflow
or by Paul
Published on 2010-05-06T08:15:15Z
Indexed on
2010/05/06
8:18 UTC
Read the original article
Hit count: 191
I've got a abstract class
class A {
public:
virtual void somefunction() = ;
};
and some different classes that inherit this class:
class Ab {
public:
void somefunction();
};
etc.
I want to make a vector containing some objects of these classes (how many depends on input parameters) so I can access these easily later. However I'm a bit lost on how to do this. My best idea is
vector<A> *objectsVector;
Ab AbObject;
objectsVector.push_back(AbObject);
However this gives me a huge amout of errors from various .h files in /usr/include/c++
How should i solve this?
© Stack Overflow or respective owner