Answer» Well, thanks to everybody for having this excelent forum where we the prentices can learn a lot of things about this programmer world.
I have the problem that follows: I must to build a PROGRAM in C++ that has two classes, cars and customers, each one with some cars and some customers, a a third class of orders, who references the before classes by references. Its is need to join one car object with one client object, but I can´t do because I don´t know how do it.
Because I have the truly code which has 11 pages with code, I have simplified the original code and problem to this other code that follows, but it compiles but it doesn´t execute because I must have made a MISTAKE in it.
I ask for your help, and I need the necesary code to see how it works joining the client and the car in one order and how the data of both is printed. Thanks.
#include #include #include #include class car_c // { int number; char brand [10]; public: car_c(); ~car_c(); void registry(); void print(); };
class client_c //here we give register to a new customer { int number; char name [10]; public: client_c(); ~client_c(); void registry(); void print(); };
//Here we build the class order, we build a link by reference //to the other before classes, and it´s need to do an order with the client we //have and the car we have.
class order_c { client_c &clients car_c &cars int order_numbers; public: order_c(); order_c (client_c &client, car_c &car); ~order_c(); void registry();//Here it´s need to build a function to join our client with //our car and building our first order.
void print();//here it´s need to build a function that prints our client and //car data. };
void main() { car_c car; client_c client; order_c order; //order.registry(); car.registry(); car.print(); client.registry(); client.print(); cin.get(); cin.get(); }
order_c::order_c (client_c &client, car_c &car):clients (client), cars (car) { order_numbers=0; }
void client_c::print() { cout << number; cout << '\n' << name; }
void client_c::registry() { cout << "INSERT the client´s name: "; cin >> name; }
client_c::~client_c() { cout << "Destroying clients... Push one key "; cin.get(); }
client_c::client_c() { number=1; }
void car_c::print() { cout << number; cout << '\n' << brand; }
void car_c::registry() { cout << "Insert brand of the car: "; cin >> brand; }
car_c::car_c() { number=1; }
car_c::~car_c() { cout << "Destroying cars... Push one key "; cin.get(); }I´m WRITTING to give thanks, because I have got link the two external classes in my true code in C++.
Thanks again.
|