Object oriented errors.

I am still new to object oriented programming and tend to screw up the syntax.

Customer.h file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#pragma once
class Customer
	{
		public:
			Customer();
			Customer(int arrivalTime, int serviceTime, int departureTime);
			virtual ~Customer();
			void setArrivalTime(int newArrivalTime);
			void setDepartureTime(int newDepartureTime);
			void setServiceTime(int newServiceTime);
			int getArrivalTime();
			int getDepartureTime();
			int getServiceTime();

		Private:
			int arrivalTime;
			int departureTime;
			int serviceTime;

	};


Customer.cpp file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "Customer.h"
#include <iostream>
using namespace std;

Customer::Customer()
{
	arrivalTime = 0;
	serviceTime = 0;
	departureTime = 0;
}

Customer::Customer(int arrivalTime, int serviceTime, int departureTime)
{
	arrivalTime = newArrivalTime;
	serviceTime = newServiceTime;
	departureTime = newDepartureTime;

}

Customer::~Customer ()
{
	cerr << "Customer::~Customer\n";
}

void Customer::setArrivalTime(int newArrivalTime)
{
        arrivalTime = newArrivalTime;
}

void Customer:: setServiceTime(int newServiceTime)
{
    serviceTime = newServiceTime;
}

void Customer:: setDepartureTime(int newDepartureTime)
{
    departureTime = newDepartureTime;
}

int Customer:: getArrivalTime(){return arrivalTime;}

int Customer:: getServiceTime(){return serviceTime;}

int Customer:: getDepartureTime(){return departureTime;}


Getting the errors below. Not sure what to do???


C:\Users\CRBottini\Desktop\Lab5\Customer.h|16|error: expected primary-expression before 'int'|
C:\Users\CRBottini\Desktop\Lab5\Customer.h|16|error: ISO C++ forbids declaration of 'Private' with no type|
C:\Users\CRBottini\Desktop\Lab5\Customer.h|16|error: expected ';' before 'int'|
C:\Users\CRBottini\Desktop\Lab5\Customer.cpp||In constructor 'Customer::Customer()':|
C:\Users\CRBottini\Desktop\Lab5\Customer.cpp|8|error: 'arrivalTime' was not declared in this scope|
C:\Users\CRBottini\Desktop\Lab5\Customer.cpp||In member function 'void Customer::setArrivalTime(int)':|
C:\Users\CRBottini\Desktop\Lab5\Customer.cpp|28|error: 'arrivalTime' was not declared in this scope|
C:\Users\CRBottini\Desktop\Lab5\Customer.cpp||In member function 'int Customer::getArrivalTime()':|
C:\Users\CRBottini\Desktop\Lab5\Customer.cpp|41|error: 'arrivalTime' was not declared in this scope|
||=== Build finished: 6 errors, 0 warnings ===|
I don't know for sure, but on line 15 of your header file, it looks like you capitalized the keyword "private". It should be a lowercase p. That error is cascading by causing the compiler to not parse the declaration of "arrivalTime" which is causing every usage of that variable to also be an error. In short, make the p in "private" on line 15 lower case and it should fix the problem.
in c++ all keywords are not capitalized. The fact that your Private is not blue should make that clear..
Topic archived. No new replies allowed.