#include <iostream>
#include <vector>
using namespace std;
class superClass {
public:
int superNumber;
};
class subClass: public superClass {
public:
int subNumber;
};
int main() {
////////a vector of subclasses
std::vector<subClass> subvector;
//////////make an instance of subclass and superclass
subClass subclass;
superClass superclass;
//////////add a subclass to the subclass vector
subvector.push_back( subclass );
////////// and now the part i want to know...
////////// make a vector of superclass pointer, and have it point to a
////////// vector of subclasses.... should work?????
////////// code compiles, but i can only access the first vector in the subclass
////////// vector using the superclass vector pointer.... why?
std::vector<superClass> * supervector;
supervector = (std::vector<superClass>*)&subvector;
return 1;
}
#include <vector>
using namespace std;
class superClass {
public:
int superNumber;
};
class subClass: public superClass {
public:
int subNumber;
};
int main() {
////////a vector of subclasses
std::vector<subClass> subvector;
//////////make an instance of subclass and superclass
subClass subclass;
superClass superclass;
//////////add a subclass to the subclass vector
subvector.push_back( subclass );
////////// and now the part i want to know...
////////// make a vector of superclass pointer, and have it point to a
////////// vector of subclasses.... should work?????
////////// code compiles, but i can only access the first vector in the subclass
////////// vector using the superclass vector pointer.... why?
std::vector<superClass> * supervector;
supervector = (std::vector<superClass>*)&subvector;
return 1;
}
