Well, since I missed the introductory thread a couple weeks ago, I'll introduce myself here... I'm a freshman majoring in CS at Rensselaer Polytechnic Institute in upstate New York. My programming experience began many years ago, in GW-BASIC. Since then, I've dabbled in several other languages, Perl being my personal favorite.
Anyway, here's my C++ question...
Is it possible to create 2 classes which contain member variables of the other's type?
Stripped-down versions of the classes:
class Edge {
public:
Edge() {}
Vertex *start;
Vertex *end;
};
class Vertex {
public:
Vertex() {}
vector<Edge *> edges;
};
This complains about the Vertex type in the Edge class; if I put the Vertex class first, it complains about the Edge type in the Vertex class (although there are many more errors this way because it's confusing the templated vector class). My question: is there any way to do this? I've had trouble with this before, but I've simply changed my approach. And this would be useful to be able to do if it's possible...
Anyway, here's my C++ question...
Is it possible to create 2 classes which contain member variables of the other's type?
Stripped-down versions of the classes:
class Edge {
public:
Edge() {}
Vertex *start;
Vertex *end;
};
class Vertex {
public:
Vertex() {}
vector<Edge *> edges;
};
This complains about the Vertex type in the Edge class; if I put the Vertex class first, it complains about the Edge type in the Vertex class (although there are many more errors this way because it's confusing the templated vector class). My question: is there any way to do this? I've had trouble with this before, but I've simply changed my approach. And this would be useful to be able to do if it's possible...
