School Project Problem - Non-static member functions

Hello folks,

I'm new here, and just beginning my programming knowledge. I'm working on this program for school and I'm getting an error about accessing non-static member functions. The class that is spawning the errors is a composite object of a derived class, which is derived from an abstarct class. The composite object is throwing these errors with every single function call to it's parent object, and I don't know why. I'm still learning how to do this stuff.

Below is the class header file. I haven't created a main program file yet.

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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
//This file contains a series of classes to create an ultralight aircraft.
//Written by Cory Phillips for DeVry University course CIS247C
//Instructor Mahbubul Chowdhury

#include <iostream>

using namespace std;

class Airplane { //Abstract Class
	protected:
		int wingSpan;	//all dimensions in SAE Standard (foot, inch, and pound)
		int length;
		int weight;
		int engineCount;
		int currentBankAngle; //positive is right bank, negative is left bank
		int currentPitchAngle; //positive is up pitch, negative is down pitch
		int currentThrottle; //speed from one to ten
	public:
		void virtual changeThrottle(int); //parameter: int 1 - 10
		void virtual bankLeft();	//will bank the aircraft a default amount of 30 degrees
		void virtual bankRight();
		void virtual bankCustom(int);	//overloaded function allowing a custom bank angle to be input (right = Positve, Left = Negative)
		void virtual pitchUp();	//pitches the aircraft up in 10 degree inceaments
		void virtual pitchDown();
		void virtual centerBank() =0; //pure virtual functions to be defined in later classes
		void virtual centerPitch() =0;

		//constructors
		Airplane();
		Airplane(int, int, int, int); //custom constructor to define span, length, weight, and number of engines - cannot custom define bank, pitch, or throttle settings
};

class Pilot{
	private:
		int height;		//height in inches, weight in pounds
		int weight;
	public:
		void bankToLeft();
		void bankToRight();
		void bankCustom(int); //input desired bank angle (positive = right, negative = left, max angle 70(-70))
		void bankLevel(); //reset the bank angle to 0
		void pitchUp();
		void pitchDown();
		void pitchLevel(); //reset the pitch angle to 0
		void setThrottle(int); //input the desired throttle setting (1-10)

		//constructors
		Pilot();
		Pilot(int, int);
};

class Ultralight: public Airplane{
	protected:
		int maxBankAngle;
		int maxPitchAngle;

		Pilot pilotInCommand; //Composite Object
	public:
		void centerBank();
		void centerPitch();

		//constructors
		Ultralight();
		Ultralight(int, int, int, int); //parameters (span, length, weight, engines)
};

//BEGIN AIRPLANE FUNCTION DEFINITION LIST
Airplane::Airplane(){
	wingSpan = 20;
	length = 35;
	weight = 2000;
	engineCount = 1;
	currentBankAngle = 0;
	currentPitchAngle = 0;
	currentThrottle = 0;
};

Airplane::Airplane(int inSpan, int inLength, int inWeight, int inEngines){
	wingSpan = inSpan;
	length = inLength;
	weight = inWeight;
	engineCount = inEngines;
	currentBankAngle = 0;
	currentPitchAngle = 0;
	currentThrottle = 0;
};

void Airplane::changeThrottle(int newThrottle){
	if ((newThrottle > 0) && (newThrottle < 11)){
		currentThrottle = newThrottle;
	}
	else{
		cout << "Invalid throttle setting; Please input throttle setting again (1-10)" << endl;
	}
};

void Airplane::bankLeft(){
	currentBankAngle = -30;
};

void Airplane::bankRight(){
	currentBankAngle = 30;
};

void Airplane::bankCustom(int newBankAngle){
	if ((newBankAngle > -70) && (newBankAngle < 70)){
		currentBankAngle = newBankAngle;
	} 
	else{
		cout << "Aircraft cannot bank greater than 70 degrees. Please input a bank value between -70 and 70" << endl;
	}
};

void Airplane::pitchUp(){
	currentPitchAngle = currentPitchAngle + 10;
};

void Airplane::pitchDown(){
	currentPitchAngle = currentPitchAngle - 10;
};
//END AIRPLANE FUNCTION DEFINITION LIST

//BEGINE PILOT FUNCTION DEFINITION LIST
Pilot::Pilot(){
	height = 72;
	weight = 180;
};

Pilot::Pilot(int inHeight, int inWeight){
	height = inHeight;
	weight = inWeight;
};

void Pilot::bankToLeft(){
	Ultralight::bankLeft(); //these are causing the problem
};

void Pilot::bankToRight(){
	Ultralight::bankRight();
};

void Pilot::bankCustom(int newBank){
	Ultralight::bankCustom(newBank);
};

void Pilot::bankLevel(){
	Ultralight::centerBank();
};

void Pilot::pitchUp(){
	Ultralight::pitchUp();
};

void Pilot::pitchDown(){
	Ultralight::pitchDown();
};

void Pilot::pitchLevel(){
	Ultralight::centerPitch();
};
void Pilot::setThrottle(int newThrottle){
	Ultralight::changeThrottle(newThrottle);
};
//END PILOT FUNCTION DEFINITION LIST

//BEGINE ULTRALIGHT FUNCTION DEFINITION LIST
Ultralight::Ultralight(int inSpan, int inLength, int inWeight, int inEngines){
	wingSpan = inSpan;
	length = inLength;
	weight = inWeight;
	engineCount = inEngines;
	currentBankAngle = 0;
	currentPitchAngle = 0;
	currentThrottle = 0;

};

Ultralight::Ultralight(){
	wingSpan = 18;
	length = 22;
	weight = 800;
	engineCount = 1;
	currentBankAngle = 0;
	currentPitchAngle = 0;
	currentThrottle = 0;
};

void Ultralight::centerBank(){
	currentBankAngle = 0;
};

void Ultralight::centerPitch(){
	currentPitchAngle = 0;
};
//END ULTRALIGHT FUNCTION DEFINITION LIST 
Your pilot class does not have any Ultralight members, so you can't call any of Ultralight's member functions.
Topic archived. No new replies allowed.