[Error] no '' member function declared in class ''

I've been stuck on this problem for a while. The program compiles if I remove the definition of VideoTape::ComparedTo from VideoTape.cpp.


Error is:
230 73 [Error] no 'RelationType VideoTape::ComparedTo(VideoTape) const' member function declared in class 'VideoTape'

28 VideoStore Program w. ComparedTo\Makefile.win recipe for target '../VideoTape.o' failed

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
//***************************************************************************
// SPECIFICATION FILE (VideoTape.h)
// This file gives the specification of a VideoTape ADT and provides a
// data type for storing first and last names. 
//***************************************************************************
#ifndef VIDEOTAPE_H
#define VIDEOTAPE_H

#include <string>

struct NameType
{
	string firstName;		// First name
	string lastName;		// Last name
};

enum RelationType {BEFORE, SAME, AFTER};

const int MAX_STARS = 5;	// Maximum number of starring actors

class VideoTape
{
	public:
		string GetTitle() const;
			// Postcondition:
			//		Function value == title
			
		int GetNumCopies() const;
			// Postcondition:
			//		Function value == numCopies
			
		void GetMovieStars( /* inout */ NameType outStars[] ) const;
			// Precondition:
			//		outStars is assigned
			//	&&	outStars is an array of size 5
			// Postcondition:
			//		outStars[0..5] == movieStars[0..5]
		
		NameType GetProducer() const;
			// Postcondition:
			//		Function value == producer
		
		NameType GetDirector() const;
			// Postcondition:
			//		Function value == director
			
		string GetProdCompany() const;
			// Postcondition:
			//		Function value == prodCompany
			
		void AdjustNumCopies( /* in */ int copies );
			// Precondition:
			//		copies is assigned
			// Postcondition:
			//		numCopies += copies
			//		(to subtract copies, enter a negative value)
			
		bool CheckIfAvailable() const;
			// Postcondition:
			//		Function value == true, if numCopies > 0
			//		Function value == false, otherwise
			
		void CheckIn();
			// Postcondition:
			//		numCopies == numCopies@call + 1
			
		void CheckOut();
			// Precondition:
			//		CheckIfAvailable == true
			// Postcondition:
			//		numCopies == numCopies@call - 1
		
		RelationType VideoTape::ComparedTo( /* in */ VideoTape otherVideoTape ) const;
			// Precondition:
			//		otherVideoTape is assigned
			// Postcondition:
			//		Function value == BEFORE, if title comes before otherVideoTape's title in the dictionary
			//					   == SAME, if titles are the same
			//					   == AFTER, if title comes after otherVideoTape's title in the dictionary
			
		void PrintTitle() const;
			// Postcondition:
			//		title has been printed
		
		VideoTape( /* in */ string initTitle, 		
				   /* in */ int initCopies, 
				   /* in */	NameType initStars[],
				   /* in */	NameType initProducer, 
				   /* in */	NameType initDirector, 
				   /* in */	string initProdCompany );
			// Precondition:
			//		initTitle, initNumCopies, initStars[], initProducer, initDirector, and initProdCompany are assigned
			//	&&	initStars[] is an array of size 5
			// Postconidition:
			//		title == initTitle
			//	&&	numCopies == initCopies
			//	&& 	movieStars[0..5] == initStars[0..5]
			//	&&	producer == initProducer
			//	&& 	director == initDirector
			//	&& 	prodCompany == initProdCompany
		
		VideoTape();								// Default constructor
			// Postcondition:
			//		title == ""
			//	&&	numCopies == 0
			//	&&	movieStars[0..5]
			//			firstName == ""
			//			lastName == ""
			//	&&	producer
			//			firstName == ""
			//			lastName == ""
			//	&&	director
			//			firstName == ""
			//			lastName == ""
			//	&&	prodCompany == ""
			
	private:
		string title;								// Title of movie
		int numCopies;								// Number of copies
		NameType movieStars[MAX_STARS];				// Starring actors
		NameType producer;							// Producer
		NameType director;							// Director
		string prodCompany;							// Production company
};
#endif 
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
//*******************************************************************
// IMPLEMENTATION FILE (VideoTape.cpp)
// This file implements the VideoTape class member functions.
//*******************************************************************

#include "VideoTape.h"
#include <iostream>

using namespace std;

// Private members of class:
//		string title;								   Title of movie
//		int numCopies;								   Number of copies
//		NameType movieStars[MAX_STARS];				   Starring actors
//		NameType producer;							   Producer
//		NameType director;							   Director
//		string prodCompany;							   Production company

//*******************************************************************

VideoTape::VideoTape()

// Default constructor

// Postcondition:
//		title == ""
//	&&	numCopies == 0
//	&&	movieStars[0..5]
//			firstName == ""
//			lastName == ""
//	&&	producer
//			firstName == ""
//			lastName == ""
//	&&	director
//			firstName == ""
//			lastName == ""
//	&&	prodCompany == ""

{
	int starsIndex;			// Index for movieStars[]
	
	title = "";
	numCopies = 0;
	
	for( starsIndex = 0; starsIndex < MAX_STARS; starsIndex++ )
	{
		movieStars[starsIndex].firstName = "";
		movieStars[starsIndex].lastName = "";
	}
	
	producer.firstName = "";
	producer.lastName = "";
	
	director.firstName = "";
	director.lastName = "";
	
	prodCompany = "";
}

//*******************************************************************

VideoTape::VideoTape( /* in */ string initTitle, 		
				   /* in */ int initCopies, 
				   /* in */	NameType initStars[],
				   /* in */	NameType initProducer, 
				   /* in */	NameType initDirector, 
				   /* in */	string initProdCompany )
			
// Precondition:
//		initTitle, initNumCopies, initStars[], initProducer, initDirector, and initProdCompany are assigned
//	&&	initStars[] is an array of size 5

// Postcondition:
//		title == initTitle
//	&&	numCopies == initCopies
//	&& 	movieStars[0..5] == initStars[0..5]
//	&&	producer == initProducer
//	&& 	director == initDirector
//	&& 	prodCompany == initProdCompany

{
	int starsIndex;			// Index for movieStars[]
	
	title = initTitle;
	
	numCopies = initCopies;
	
	for( starsIndex = 0; starsIndex < MAX_STARS; starsIndex++ )
	{
		movieStars[starsIndex].firstName = initStars[starsIndex].firstName;
		movieStars[starsIndex].lastName = initStars[starsIndex].lastName;
	}
	
	producer = initProducer;
	
	director = initDirector;
	
	prodCompany = initProdCompany;
}

//*******************************************************************

string VideoTape::GetTitle() const

// Postcondition:
//		Function value == title

{
	return title;
}

//*******************************************************************

int VideoTape::GetNumCopies() const

// Postcondition:
//		Function value == numCopies

{
	return numCopies;
}

//*******************************************************************

void VideoTape::GetMovieStars( /* inout */ NameType outStars[] ) const

// Precondition:
//		outStars is assigned
//	&&	outStars is an array of size 5

// Postcondition:
//		outStars[0..5] == movieStars[0..5]

{
	int starsIndex;			// Array index
	
	for( starsIndex = 0; starsIndex < MAX_STARS; starsIndex++ )
	{
		outStars[starsIndex] = movieStars[starsIndex];
	}
}

//*******************************************************************

NameType VideoTape::GetProducer() const

// Postcondition:
//		Function value == producer

{
	return producer;
}

//*******************************************************************

NameType VideoTape::GetDirector() const

// Postcondition:
//		Function value == director

{
	return director;
}

//*******************************************************************

string VideoTape::GetProdCompany() const

// Postcondition:
//		Function value == prodCompany

{
	return prodCompany;
}

//*******************************************************************

void VideoTape::AdjustNumCopies( /* in */ int copies )

// Precondition:
//		copies is assigned

// Postcondition:
//		numCopies += copies
//		(to subtract copies, enter a negative value)

{
	numCopies += copies;
}

//*******************************************************************

bool VideoTape::CheckIfAvailable() const

// Postcondition:
//		Function value == true, if numCopies > 0
//		Function value == false, otherwise

{
	return numCopies > 0;
}

//*******************************************************************

void VideoTape::CheckIn()

// Postcondition:
//		numCopies == numCopies@call + 1

{
	numCopies++;
}

//*******************************************************************

void VideoTape::CheckOut()

// Precondition:
//		CheckIfAvailable == true

// Postcondition:
//		numCopies == numCopies@call - 1

{
	numCopies--;
}

//*******************************************************************

RelationType VideoTape::ComparedTo( /* in */ VideoTape otherVideoTape ) const

// Precondition:
//		otherVideoTape is assigned

// Postcondition:
//		IF title < otherVideoTape title
//			Function value == BEFORE
//		ELSE IF title > otherVideoTape title
//			Function value == AFTER
//		ELSE
//			Function value == SAME


{
	if( title < otherVideoTape.GetTitle() )
		return BEFORE;
	else if( title > otherVideoTape.GetTitle() )
		return AFTER;
	else
		return SAME;
}

//*******************************************************************

void VideoTape::PrintTitle() const

// Postcondition:
//		title has been printed

{
	cout << title;
}
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
//***************************************************************
// Video Tape driver
// This program tests the VideoTape member functions declared in VideoTape.h
//***************************************************************

#include "VideoTape.h"
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string title;				// Title of input movie
	int copies;					// Number of copies of input movie
	NameType movieStars[5];		// Stars in input movie (max 5)
	NameType producer;			// Producer's name
	NameType director;			// Director's name
	string prodCompany;			// Production company
	NameType outStars[5];		// Movie stars array to set GetMovieStars()
	int addCopies;				// Number of copies to add, tests AdjustNumCopies
	int index;					// Array index
	
	title = "A Movie";
	copies = 3;
	
	movieStars[0].firstName = "John";
	movieStars[0].lastName = "Smith";
	movieStars[1].firstName = "Washington";
	movieStars[1].lastName = "Irving";
	movieStars[2].firstName = "Charlie";
	movieStars[2].lastName = "Chaplain";
	movieStars[3].firstName = "Jane";
	movieStars[3].lastName = "Doe";
	movieStars[4].firstName = "Donald";
	movieStars[4].lastName = "Duck";
	
	producer.firstName = "Steven";
	producer.lastName = "Spielberg";
	
	director.firstName = "John";
	director.lastName = "Lucas";
	
	prodCompany = "MGM";
	
	// Test Constructors
	
	VideoTape blankTape;
	VideoTape videoTape( title, copies, movieStars, producer, director, prodCompany );
	
	
	// Test GetTitle()
	
	cout << "Title:" << endl;
	cout << blankTape.GetTitle() << endl;
	cout << videoTape.GetTitle() << endl << endl;
	

	// Test GetNumCopies()
	
	cout << "Copies:" << endl;
	cout << blankTape.GetNumCopies() << endl;
	cout << videoTape.GetNumCopies() << endl << endl;
	

	// Test GetMovieStars()
	
	cout << "Movie Stars:" << endl;
	
	blankTape.GetMovieStars( outStars );
	
	for( index = 0; index < 5; index++ )
		cout << outStars[index].lastName << ", " << outStars[index].firstName << endl;
	
	videoTape.GetMovieStars( outStars );
	
	for( index = 0; index < 5; index++ )
		cout << outStars[index].lastName << ", " << outStars[index].firstName << endl;
	
	cout << endl << endl;	
	

	// Test GetProducer()
	
	cout << "Producer: " << endl;
	producer = blankTape.GetProducer();
	cout << producer.lastName << ", " << producer.firstName << endl;
	producer = videoTape.GetProducer();
	cout << producer.lastName << ", " << producer.firstName << endl << endl;
	
	
	// Test GetDirector()
	
	cout << "Director: " << endl;
	director = blankTape.GetDirector();
	cout << director.lastName << ", " << director.firstName << endl;
	director = videoTape.GetDirector();	
	cout << director.lastName << ", " << director.firstName << endl << endl;
	
	
	// Test GetProdCompany()
	
	cout << "Production Company: " << endl;
	cout << blankTape.GetProdCompany() << endl;
	cout << videoTape.GetProdCompany() << endl << endl;
	
	
	// Test AdjustNumCopies
	
	videoTape.AdjustNumCopies( 2 );
	
	cout << "Video Tape + 2 copies: " << endl;
	cout << videoTape.GetNumCopies() << endl << endl;
	
	
	// Test CheckIfAvailable()
	
	cout << "Is movie available?" << endl;
	
	cout << blankTape.GetTitle() << ":this is the blank object: " << blankTape.CheckIfAvailable() << endl;
	cout << videoTape.GetTitle() << ": " << videoTape.CheckIfAvailable() << endl << endl;
	
	
	// Test CheckIn()
	
	cout << "CheckIn test: " << endl;
	cout << videoTape.GetNumCopies() << endl;
	
	videoTape.CheckIn();
	
	cout << videoTape.GetNumCopies() << endl << endl; 
	
	
	// Test CheckOut()
	
	cout << "CheckOut test: " << endl;
	cout << videoTape.GetNumCopies() << endl;
	
	videoTape.CheckOut();
	
	cout << videoTape.GetNumCopies() << endl << endl;
	
	
	// Test PrintTitle()
	
	cout << "Print test: " << endl;
	cout << "Blank tape: ";
	blankTape.PrintTitle();
	cout << endl;
	
	cout << "Video Tape: ";
	videoTape.PrintTitle();
	cout << endl << endl;
	
	cout << "End test.";
	
	return 0;
}
Compile Log

Compiling project changes...
--------
- Project Filename: C:\Dev-Cpp\Chapter 14\VideoStore Program w. ComparedTo\VideoStore Program w. ComparedTo
- Compiler Name: TDM-GCC 4.9.2 64-bit Release

Building makefile...
--------
- Filename: C:\Dev-Cpp\Chapter 14\VideoStore Program w. ComparedTo\Makefile.win

Processing makefile...
--------
- Makefile Processor: C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\mingw32-make.exe
- Command: mingw32-make.exe -f "C:\Dev-Cpp\Chapter 14\VideoStore Program w. ComparedTo\Makefile.win" all

g++.exe -D__DEBUG__ -c ../VideoTape.cpp -o ../VideoTape.o -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++" -g3

../VideoTape.cpp:230:73: error: no 'RelationType VideoTape::ComparedTo(VideoTape) const' member function declared in class 'VideoTape'
RelationType VideoTape::ComparedTo( /* in */ VideoTape otherVideoTape ) const
^

C:\Dev-Cpp\Chapter 14\VideoStore Program w. ComparedTo\Makefile.win:28: recipe for target '../VideoTape.o' failed

mingw32-make.exe: *** [../VideoTape.o] Error 1


Compilation results...
--------
- Errors: 1
- Warnings: 0
- Output Filename: C:\Dev-Cpp\Chapter 14\VideoStore Program w. ComparedTo\VideoStore Program w.exe
- Output Size: 1.98900318145752 MiB
- Compilation Time: 0.78s
In your VideoTape.h, line 73:

RelationType VideoTape::ComparedTo( /* in */ VideoTape otherVideoTape ) const;

Remove the VideoTape::.

What you should have is:

RelationType ComparedTo( /* in */ VideoTape otherVideoTape ) const;
Topic archived. No new replies allowed.