Hi im having a little problem understanding how class pointers work. Ill explain as best i can what i dont understand...
My problem:
Im trying to do a simple graph like data structure, and am having a few problems understanding how to reference the pointers and use them, also if im using them correctly.
The class A should be able to point to 6 neighbours of class A, each of these neighbours in turn have 6 neighbours and so on.
I have a class A like so
Code:
class A
{
public:
A();
~A();
A *one, *two, *three, *four, *five, *six;
};
In A how do i reference the one two etc? Im trying something like below but am having problems.
Code:
#include <iostream>
#include "A.h"
using namespace std;
int main(int argc, char *argv[])
{
A a,b;
// a's first neighbour points to b's four neighbour
a.one = b;
b.four = a;
return 0;
}
How do i get the pointer from a.one to point to object b? Am i using the correct notation? Sorry im new to pointers...!
Also have i defined the class A correctly for the problem im doing?
Sorry if this is a little vague!!!
Thanks