The whole point of my current project is to write a graph of sorts and my problem at this early stage is the weighted link data type which basically attaches an integer value to the pointer. Please bear in my I'm treating this as an extension of a tree.
Code:
//------------------------------------ Enumerations -----------------------------------
enum colour {None, Green, Blue, Grey, Yellow, Black, Orange, Red, Brown, Pink, Maroon};
const string line_name[] = {"None", "District", "Picadilly", "Jubilee", "Circle",
"North_London", "East_London", "Central", "Bakerloo",
"Hammersmith_City", "Metropolitan"};
//--------------------------------------------------------------------------------------
//----------------------------- structure definition -----------------------------------
template <class cl_pntr> struct weighted_link {
int weight;
colour line_colour;
cl_pntr *link;
void setinfo(int w, colour lc, cl_pntr &lnk); //<------------- Not sure how to pass the 3rd parameter. And this is where my problem stems from
}; //ends weighted_link
template<class cl_pntr> void weighted_link<cl_pntr>::setinfo(int w, colour lc, cl_pntr &lnk)
{ weight = w; line_colour = lc; link = lnk }//<---------- here
//--------------------------------------------------------------------------------------
//----------------------------- station definition -------------------------------------
class uground{
string name;
int zone;
vector<weighted_link<uground *> > connections;
public:
uground();
uground(string nm, int zn){name = nm; zone = zn;}//end constructor
void setdetails(string nm, int zn){name = nm; zone = zn;}
void setlink(uground x, uground &y, int w, colour cl){
connections[connections.size()].setinfo(w, Orange, y); //<------------ here
}//end of setlink
int getzone(){return zone;}
string getname(){return name;}
int num_of_connections(){return connections.size();}
This is a snippet of code and my problem has to do with my knowledge of C++. I am aware that I'm simplifying things but the whole idea is to really get a grip with playing with C++ and learning its features.
Originally I started using auto_ptr but I'm not entirely sure how they work.