Class attributes


Hi, im yet another student doing the flight booking system project, so far i have declared a number of classes for the program - most of which compile fine. having trouble with including a char variable within the class. i know i need it but i dont know how to set it up within the class.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class Passenger
{
public:
       Passenger(char GetpassName[100], int GetbusinessCustomer, bool Promotion, int passType, int residence);
       ~Passenger();
       char GetpassName[100] {return itspassName[100];}
       void SetPassName (char GetpassName[100]) {itspassName[100] = GetpassName[100];}
       int GetbusinessCustomer() {return itsBusinessCustomer; }
       void SetBusinessCustomer(int GetbusinessCustomer) {itsBusinessCustomer = GetbusinessCustomer; }
       bool promotion();
       int passType() {return itsPassType; }
       void setpassType (int passType) {itsPassType = passType; }
       int residence() {return itsResidence; }
       void setResidence (int residence) {itsResidence = residence; }
private:
        char itspassName[100];
        int itsBusinessCustomer;
        int itsPassType;
        int itsResidence;
};


any suggestions or hints to where im going wrong?

J
char GetpassName[100] {return itspassName;}
1
2
3
4
void SetPassName (char GetpassName[100]) {
   for (short i=0; i<100; i++)
      itspassName[i] = GetpassName[i];//set each character
}


remember that array_name[number] is the (number+1)th element of the array and array_name[array_size] will be 1 over the last element

If you are using character array as strings, a better solution would be using std::strings
Last edited on
thanks for your solution!

think i understand it, appriciated :)
Topic archived. No new replies allowed.