Please help! - TechRepublic
General discussion
March 12, 2003 at 02:10 PM
foe

Please help!

by foe . Updated 23 years, 3 months ago

I have just started uni and I am doing c++. My question is how do you pass or add an object of one type to another class? For example suppose you have two classes, 1 – a Vehicle class, and 2 – a FuelPurchase class. In the driver program I want to beable to add FuelPurchase to Vehicle by overloading the + operator in the Vehicle class e.g.

int main(){
Vehicle a(“Manufacturer”,”Holden”,2003″);
a = a + FuelPurchase(100,70);
return 0;
}

Well that is my question (I hope that I explained my problem enough), if any one could help me out it would be much appreciated.

This discussion is locked

All Comments