ok in the first function i am suppose to read in the data from the file for the next node, allcatees the node, assigns the members, and return a pointer to the new node through the function return type i have no idea how to do that can you look at it a see what i am missing.
int CreateMotorcycle(Motorcycles *&FirstBike)
{
Motorcycles * NewMotorcycle = FirstBike;
//To Get the Model of the Motorcycle
getline(infile,FirstBike->Model);
//to get the stock number of the Motorcycle
infile>>FirstBike->StockNum;
//to skip the remaining '\n' character
infile.ignore();
//to get the sytle of the Motorcycle
getline(infile,FirstBike->Style);
//to get the Price of the Motorcycle
infile>>FirstBike->Price;
//to get the HorsePower of the Motorcycle
infile>>FirstBike->Hp;
}
in this function i am add the node that was created in the function above and add it to the end of the list i just wondering how i can return FirstBike which is the head pointer.
int AddToModel(Motorcycles*&FirstBike,Motorcycles *NewMotorcycle)//to add the bike to the end of the list
{
Motorcycles*tptr=FirstBike; //to traverse thur the list
Motorcycles*newNode=NULL;
if(!FirstBike)
FirstBike=newNode;
else
{
tptr= FirstBike;
while(tptr->nextmotorcycle)
tptr=tptr->nextmotorcycle;
tptr->nextmotorcycle=newNode;
}
}
the file looks like this the numbers beside the motorcycles are suppose to get read in to tell the compiler what function to call.
1Honda RC51
1232
Super
9895.95 125
1Suzuki GSXR750
2134
Super
6395.95 110
1Yamaha V-Star1100
4892
Cruiser
7458.95 123
1Harley VRod1300
1321
Cruiser
23855.95 92
1Suzuki Katana600
8873
Sport
4593.95 87
1Honda SuperHawk
3971
Sport
5789.95 105
1Harley VTR100
5372
Super
12393.95 135
1Honda NightHawk
4725
Street
3494.95 79
1Yamaha V-Max1200
9421
Street
8794.95 112
1CBRF4i600
6722
Sport
6785.95 95
1Harley Big Dog
7923
Cruiser
17828.95 88
1Suzuki GS850
7319
Street
2395.95 75
1Honda GoldwingGL1500
3412
Cruiser
14959.95 93
1Harley FLHR
9347
Cruiser
12939.95 70
1Suzuki Intruder1400
6895
Cruiser
8737.95 110
3
4 8000.00
4 10000.00
4 1000.00
5Super
5Cruiser
6Yamaha
1Yamaha YZF-R1
1110
Super
9388.95 125
3
1Yamaha YZF-R6
9982
Street
5896.95 90
3
6Yamaha
6Kawasaki
2 4725
2 5555
2 1110
1Kawasaki Ninja1200Z
8885
Super
12896.95 131
3
7