Hello folks
I'm trying to do my assignment and I'm really stuck in!
I have to classes..Customer and Pensioner (Customer = Super class and Pensioner = Subclass)
The Pensioner has a PensionNo extra than Customer class.
I have to make a array of Customer class (for 10) and put Customer and Pensioner in it. Then I have to override << operator and print out the values of Customer/Pensioner in a file.
Customer.h
#ifndef CUSTOMER_H
#define CUSTOMER_H
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
class Customer {
public:
Customer(string _firstname, string _lastname, string _telephone, int _noofcall);
friend ostream& operator << (ostream& out, Customer _customer);
string getFirstName();
string getLastName();
string getTelephone();
int getNoOfCall();
protected:
string firstName;
string lastName;
string telephone;
int noOfCall;
};
#endif
Pensioner.h
#ifndef PENSIONER_H
#define PENSIONER_H
#include <iostream>
#include <fstream>
#include <string>
#include ".\Customer.h"
using namespace std;
class Pensioner : public Customer {
public:
string pensionNo;
Pensioner(string firstname, string lastname, string telephone, int noofcall, string pensionno) ;
friend ostream& operator << (ostream& out, Customer _customer);
string getPensionNo();
};
#endif
The main problem:
if (cmd == 'P')
{
string pension;
oss >> pension;
customers[top++] = new Pensioner(first, last, phone, Nofcalls, pension);
}
else
customers[top++] = new Customer(first, last, phone, Nofcalls);
break;
}
A Pensioner instance creates but when it put into the Customers[] it lost its pension value.
It really don't know what should i do...
I'll grateful if you can give me any hints...
Cheers