Code errors

getting the following errors in my code
puzzle.cpp(77) : error C2059: syntax error : 'return'
.\puzzle.cpp(77) : error C2238: unexpected token(s) preceding ';'
.\puzzle.cpp(79) : fatal error C1004: unexpected end-of-file found

my code is as follows:

<// puzzle.cpp : main project file.

**Assigment 2 Jigsaw Class
by Ashish Chaudhary
*/
#include "stdafx.h"
#include <iostream>
#include <iomanip>
using namespace std;

class puzzle {
char nameOfPuzzles;
int sizeOfPuzzles;
int numOfPieces;
int missingPieces;
int ListOfPuzzles;
char ratings;
char lastCompeleted;


//these are a list of attritubes which are going to be used in the puzzle class

void setNameOfPuzzles (char anameOfPuzzles)
{
anameOfPuzzles = nameOfPuzzles;
}
char getNameOfPuzzles(char anameOfPuzzles)
{
return anameOfPuzzles;
}

void setSizeOfPuzzles (int thesizeOfPuzzles)
{
thesizeOfPuzzles = sizeOfPuzzles;
}
int getSizeOfPuzzles(int thesizeOfPuzzles)
{
return thesizeOfPuzzles;
}
void setNumOfPieces (int thenumOfPieces)
{
thenumOfPieces = numOfPieces;
}
int getNumOfPieces(int thenumOfPieces) // the above methods sets the attriubes so that they are easy to return
{
return thenumOfPieces;
}

void viewRatings(int numOfPieces, char ratings)
{
if (numOfPieces >= 4)
{
rating = easy;
}
else if (numOfPieces <4&& numOfPieces >=8)
{
ratings = medium;
}
else if (numOfPieces < 8)
{
ratings = hard;
}

//the above method allows to create rating by using if statement to print out ratings

/**char createPuzzle(char nameOfpuzzles, int sizeOfPuzzles, int numOfPieces, char viewRatings)
{
cout <<"enter information about the new puzzle";
cout <<" Name Of puzzle is:"; cin>> nameOfPuzzles;
cout <<" Size Of puzzle is:"; cin>> sizeOfPuzzles;
cout <<" Number Of pieces are:";cin>> numOfPieces;
cout <<" this puzzle is rated at:";cin>> viewRatings;*/

//creates a new jiasaw puzzle

}
return 0;
}>

I can not see what the problem is please help
Please repost the code using code tags so we can match line numbers.

01// puzzle.cpp : main project file.
02
03**Assigment 2 Jigsaw Class
04by Ashish Chaudhary
05*/
06#include "stdafx.h"
07#include <iostream>
08#include <iomanip>
09using namespace std;
10
11class puzzle {
12char nameOfPuzzles;
13int sizeOfPuzzles;
14int numOfPieces;
15int missingPieces;
16int ListOfPuzzles;
17char ratings;
18char lastCompeleted;
19
20
21//these are a list of attritubes which are going to be used in the puzzle class
22
23void setNameOfPuzzles (char anameOfPuzzles)
24{
25anameOfPuzzles = nameOfPuzzles;
26}
27char getNameOfPuzzles(char anameOfPuzzles)
28{
29return anameOfPuzzles;
30}
31
32void setSizeOfPuzzles (int thesizeOfPuzzles)
33{
34thesizeOfPuzzles = sizeOfPuzzles;
35}
36int getSizeOfPuzzles(int thesizeOfPuzzles)
37{
38return thesizeOfPuzzles;
39}
40void setNumOfPieces (int thenumOfPieces)
41{
42ThenumOfPieces = numOfPieces;
43}
44int getNumOfPieces(int thenumOfPieces) // the above methods sets the attriubes so that they are easy to return
45{
46return thenumOfPieces;
47}
48
49void viewRatings(int numOfPieces, char ratings)
50{
51 if (numOfPieces >= 4)
52{
53 rating = easy;
54}
55 else if (numOfPieces <4&& numOfPieces >=8)
56{
57 ratings = medium;
58}
59else if (numOfPieces < 8)
60{
61 ratings = hard;
62}
63
64//the above method allows to create rating by using if statement to print out ratings
65
66/**char createPuzzle(char nameOfpuzzles, int sizeOfPuzzles, int numOfPieces, char viewRatings)
67{
68cout <<"enter information about the new puzzle";
69cout <<" Name Of puzzle is:"; cin>> nameOfPuzzles;
70cout <<" Size Of puzzle is:"; cin>> sizeOfPuzzles;
71cout <<" Number Of pieces are:";cin>> numOfPieces;
72cout <<" this puzzle is rated at:";cin>> viewRatings;*/
73
74//creates a new jiasaw puzzle
75
76}
77return 0;
78}


here is the code with the tags
Well, that's not with tags, but the line numbers is what I needed. Formatting/indentation
would be nice too though, and would help you diagnose the compile error.

If I read your code correctly, the brace on 76 closes the function opened on lines 49/50,
which means that the return 0; is sitting in the middle of the class declaration.
Hi sorry about this but now I am getting the following errors

------ Build started: Project: Jisaw, Configuration: Debug Win32 ------
Compiling...
Jisaw.cpp
.\Jisaw.cpp(83) : error C2059: syntax error : 'return'
.\Jisaw.cpp(83) : error C2238: unexpected token(s) preceding ';'
.\Jisaw.cpp(85) : error C2143: syntax error : missing ';' before '}'
.\Jisaw.cpp(85) : error C2059: syntax error : '}'
.\Jisaw.cpp(85) : error C2143: syntax error : missing ';' before '}'
.\Jisaw.cpp(52) : error C2562: 'puzzle::getMissingPieces' : 'void' function returning a value
.\Jisaw.cpp(50) : see declaration of 'puzzle::getMissingPieces'
.\Jisaw.cpp(59) : error C2065: 'rating' : undeclared identifier
.\Jisaw.cpp(59) : error C2065: 'easy' : undeclared identifier
.\Jisaw.cpp(63) : error C2065: 'medium' : undeclared identifier
.\Jisaw.cpp(67) : error C2065: 'hard' : undeclared identifier
.\Jisaw.cpp(85) : error C2059: syntax error : '}'
I started again to see it worked but did not the is here again

1 // puzzle.cpp : main project file.
2 //Assigment 2 puzzle program by Ashish Chaudhary
3
4 #include "stdafx.h"
5 #include <iostream>
6 #include <iomanip>
7 using namespace std;
8
9 class puzzle {
10char nameOfPuzzles;
11 int sizeOfPuzzles;
12 int numOfPieces;
13 int missingPieces;
14 int ListOfPuzzles;
15 char ratings;
16 char lastCompeleted;
17
18
19 //these are a list of attritubes which are going to be used in the puzzle class
20
21 void setNameOfPuzzles (char anameOfPuzzles)
22 {
23 anameOfPuzzles = nameOfPuzzles;
24 }
25 char getNameOfPuzzles(char anameOfPuzzles)
26 {
27 return anameOfPuzzles;
28 }
29
30 void setSizeOfPuzzles (int thesizeOfPuzzles)
31 {
32 thesizeOfPuzzles = sizeOfPuzzles;
33 }
34 int getSizeOfPuzzles(int thesizeOfPuzzles)
35 {
36 return thesizeOfPuzzles;
37 }
38 void setNumOfPieces (int thenumOfPieces)
39 {
40 thenumOfPieces = numOfPieces;
41 }
42 int getNumOfPieces(int thenumOfPieces) // the above methods sets the attriubes so that they are easy to return
43 {
44 return thenumOfPieces;
45 }
46 void setMissingPieces(int theMissingPieces)
47 {
48 theMissingPieces = missingPieces;
49 }
50 void getMissingPieces(int theMissingPieces)
51 {
52 return theMissingPieces;
53 }
54
55 void viewRatings(int numOfPieces, char ratings)
56 {
57 if (numOfPieces >= 4)
58 {
59 rating = easy;
60 }
61 else if (numOfPieces <4&& numOfPieces >=8)
62 {
63 ratings = medium;
64 }
65 else if (numOfPieces < 8)
66 {
67 ratings = hard;
68 }
69 }
70 //the above method allows to create rating by using if statement to print out ratings
71
72 char addPuzzle(char aNameOfPuzzles, int theSizeOfPuzzles, int theNumOfPieces, char viewRatings, int theMissingPieces)
73{
74 cout <<"enter information about the new puzzle";
75 cout <<" Name Of puzzle is:"; cin>> aNameOfPuzzles;
76 cout <<" Size Of puzzle is:"; cin>> theSizeOfPuzzles;
77 cout <<" Number Of pieces are:";cin>> theNumOfPieces;
78 cout <<" Number of missing pieces are:"; cin>>theMissingPieces;
79 cout <<" this puzzle is rated at:";cin>> viewRatings;
80 }
81 //creates a new jiasaw puzzle
82
83 return 0;
84}
85}


would be grateful if you could help and point it out for me

I also have a interface class which goes like this I just want help as to where the main methods need to either both the cases or after

#include "stdafx.h"
#include <iostream>
#include <iomanip>
using namespace std; // output class in c++
int choice; //attribue to allow users to enter choice

int main() // starts the program
{
do

{
cout << "Welcome to Puzzle Program " ;
cout << "please enter choice "; // The menu system the users will see and the choices they have
cout << "(1) - add Puzzle ";
cout << "(2) - Remove Puzzle";
cout << "(3) - View list of Puzzle" ;
cout << "(4) - View Ratings of puzzles";
cout << "(5) - View by num of pieces missing" ;

cin >> choice;// gets the choice from the user

switch(choice)// switch system which produces the method for the choice the users selects
{
case 1:
addPuzzle(); // these are the methods which are in the program
break;
case 2:
removePuzzle();
break;
case 3:
viewRatings();
break;
case 4:
viewNumOfMissingPieces();
break;

default : return 0;
break;
}
}while (choice!= 27);

// do-while loop to allow user to use the program until the option zero which will end program

return 0;
}



That's completely unreadable.

http://www.cplusplus.com/articles/firedraco1/
at quick glance, all it looks like you did was uncomment out line 72, which makes
the ensuing two braces more meaningful, but you didn't change the problem.

return 0; is still inside the declaration of the class.

(this is without straining my eyes too much because of your lack of indentation.)
Press the Button on the left that looks like <>
Hi sorry about that the code is now in tags

------ Build started: Project: Jisaw, Configuration: Debug Win32 ------
Compiling...
Jisaw.cpp
.\Jisaw.cpp(83) : error C2059: syntax error : 'return'
.\Jisaw.cpp(83) : error C2238: unexpected token(s) preceding ';'
.\Jisaw.cpp(85) : error C2143: syntax error : missing ';' before '}'
.\Jisaw.cpp(85) : error C2059: syntax error : '}'
.\Jisaw.cpp(85) : error C2143: syntax error : missing ';' before '}'
.\Jisaw.cpp(52) : error C2562: 'puzzle::getMissingPieces' : 'void' function returning a value
.\Jisaw.cpp(50) : see declaration of 'puzzle::getMissingPieces'
.\Jisaw.cpp(59) : error C2065: 'rating' : undeclared identifier
.\Jisaw.cpp(59) : error C2065: 'easy' : undeclared identifier
.\Jisaw.cpp(63) : error C2065: 'medium' : undeclared identifier
.\Jisaw.cpp(67) : error C2065: 'hard' : undeclared identifier
.\Jisaw.cpp(85) : error C2059: syntax error : '}'
I started again to see it worked but did not the is here again

1 // puzzle.cpp : main project file.
2 //Assigment 2 puzzle program by Ashish Chaudhary
3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
4 #include "stdafx.h"
5 #include <iostream>
6 #include <iomanip>
7 using namespace std;
8
9 class puzzle {
10char nameOfPuzzles;
11 int sizeOfPuzzles; 
12 int numOfPieces; 
13 int missingPieces;
14 int ListOfPuzzles;
15 char ratings;
16 char lastCompeleted;
17

18
19 //these are a list of attritubes which are going to be used in the puzzle class
20
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
21 void setNameOfPuzzles (char anameOfPuzzles)
22 {
23 anameOfPuzzles = nameOfPuzzles;
24 }
25 char getNameOfPuzzles(char anameOfPuzzles)
26 {
27 return anameOfPuzzles;
28 }
29
30 void setSizeOfPuzzles (int thesizeOfPuzzles)
31 {
32 thesizeOfPuzzles = sizeOfPuzzles;
33 }
34 int getSizeOfPuzzles(int thesizeOfPuzzles)
35 {
36 return thesizeOfPuzzles;
37 }
38 void setNumOfPieces (int thenumOfPieces)
39 {
40 thenumOfPieces = numOfPieces;
41 }
42 int getNumOfPieces(int thenumOfPieces) // the above methods sets the attriubes so that they are easy to return 
43 {
44 return thenumOfPieces;
45 }
46 void setMissingPieces(int theMissingPieces)
47 { 
48 theMissingPieces = missingPieces;
49 }
50 void getMissingPieces(int theMissingPieces)
51 {
52 return theMissingPieces;
53 }
54
55 void viewRatings(int numOfPieces, char ratings) 
56 { 
57 if (numOfPieces >= 4) 
58 {
59 rating = easy; 
60 }
61 else if (numOfPieces <4&& numOfPieces >=8)
62 { 
63 ratings = medium;
64 }
65 else if (numOfPieces < 8) 
66 {
67 ratings = hard; 
68 }
69 }
70 //the above method allows to create rating by using if statement to print out ratings
71


1
2
3
4
5
6
7
8
9
10
11
12
13
14
char addPuzzle(char aNameOfPuzzles, int theSizeOfPuzzles, int theNumOfPieces, char viewRatings, int theMissingPieces)
73{
74 cout <<"enter information about the new puzzle";
75 cout <<" Name Of puzzle is:"; cin>> aNameOfPuzzles; 
76 cout <<" Size Of puzzle is:"; cin>> theSizeOfPuzzles;
77 cout <<" Number Of pieces are:";cin>> theNumOfPieces; 
78 cout <<" Number of missing pieces are:"; cin>>theMissingPieces;
79 cout <<" this puzzle is rated at:";cin>> viewRatings; 
80 }
81 //creates a new jiasaw puzzle 
82
83 return 0;
84} 
85}


would be grateful if you could help and point it out for me

I also have a interface class which goes like this I just want help as to where the main methods need to either both the cases or after
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
#include "stdafx.h"
#include <iostream>
#include <iomanip>
using namespace std; // output class in c++
int choice; //attribue to allow users to enter choice

int main() // starts the program 
{
do

{
cout << "Welcome to Puzzle Program " ;
cout << "please enter choice "; // The menu system the users will see and the choices they have
cout << "(1) - add Puzzle ";
cout << "(2) - Remove Puzzle";
cout << "(3) - View list of Puzzle" ;
cout << "(4) - View Ratings of puzzles";
cout << "(5) - View by num of pieces missing" ;

cin >> choice;// gets the choice from the user 

switch(choice)// switch system which produces the method for the choice the users selects
{
case 1:
addPuzzle(); // these are the methods which are in the program 
break;
case 2:
removePuzzle();
break;
case 3:
viewRatings();
break;
case 4:
viewNumOfMissingPieces();
break;

default : return 0;
break;
}
}while (choice!= 27); 

// do-while loop to allow user to use the program until the option zero which will end program

return 0; 
}
I'm sorry but that code is still unreadable, when coding we use indentation to show block scope.
This it makes very easy to read from a simple glance, however reading this code everyone must strain to try and figure out what is going on...
Here is an example that I copied directly from my IDE, text editor. Your last post looks like you have just copied code from previous posts and stuck them in code tags which is not really what we wanted, in fact the first block still contains the numbers you stuck on each line.

also when creating your projects in VC++, you should use blank project.

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
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

void runProg();

int main()
{
   string userChoice;

   cout << "Ello' Universe" << endl;
   cout << "Would you like to play a game? Y/N" << endl;
   cin >> userChoice;

   if (userChoice.toUpper() == 'Y')
   {
      cout << "Ok lets begin..." << endl;
      runProg();  // you can easily tell this is part of 'if'
   }
   else if (userChoice.toUpper() == 'N')
      return 0;
}

void runProg()
{
      int game, num1, num2, answer;
      ... 
      // more code ...
}


Last edited on
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
			#include "stdafx.h"
			#include <iostream>
			#include <iomanip>
			using namespace std;	// output class in c++
			int choice;				//attribue to allow users to enter choice

			int main()				// starts the program 
			{
				do
				
				{
					cout << "Welcome to Puzzle Program " ;
					cout << "please enter choice ";			// The menu system the users will see and the choices they have
					cout << "(1) -   add Puzzle  ";
					cout << "(2) -   Remove Puzzle";
					cout << "(3) -   View list of Puzzle" ;
					cout << "(4) -	 View Ratings of puzzles";
					cout << "(5) -	 View by num of pieces missing" ;
					
					cin >> choice;// gets the choice from the user 

					switch(choice)// switch system which produces the method for the choice the users selects
					{
						case 1:
							add_puzzle(); // these are the methods which are in the program 
							break;
						case 2:
							remove_puzzle();
							break;
						case 3:
							view_list_of_puzzles();
							break;
						case 4:
							view_by_ratings();
							break;
						case 5:
							view_number_of_missing_pieces();
							break;
						
					default : return 0;
							break;
					}
					}while (choice!= 27); 
				
						// do-while loop to allow user to use the program until the option zero which will end program
				
				return 0; 
			}



is this better
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
			// puzzle.cpp : main project file.
			//Assigment 2 puzzle program by Ashish Chaudhary 

			#include "stdafx.h"
			#include <iostream>
			#include <iomanip>
			using namespace std;

			class puzzle {
			char nameOfPuzzles;
			int sizeOfPuzzles; 
			int numOfPieces; 
			int missingPieces;
			char ratings;



			//these are a list of attritubes which are going to be used in the puzzle class

			void setNameOfPuzzles (char anameOfPuzzles)
			{
			anameOfPuzzles = nameOfPuzzles;
			}
			char getNameOfPuzzles(char anameOfPuzzles)
			{
			return anameOfPuzzles;
			}

			void setSizeOfPuzzles (int thesizeOfPuzzles)
			{
			thesizeOfPuzzles = sizeOfPuzzles;
			}
			int getSizeOfPuzzles(int thesizeOfPuzzles)
			{
			return thesizeOfPuzzles;
			}
			void setNumOfPieces (int thenumOfPieces)
			{
			thenumOfPieces = numOfPieces;
			}
			int getNumOfPieces(int thenumOfPieces) // the above methods sets the attriubes so that they are easy to return 
			{
			return thenumOfPieces;
			}
			void setMissingPieces(int theMissingPieces)
			{	
				theMissingPieces = missingPieces;
			}
			void getMissingPieces(int theMissingPieces)
			{
				return theMissingPieces;
			}

			void viewRatings(int numOfPieces, char ratings) 
			{ 
			if (numOfPieces >= 4) 
			{
				rating = easy; 
			}
			else if (numOfPieces <4&& numOfPieces >=8)
			{ 
				ratings = medium;
			}
			else if (numOfPieces < 8) 
			{
				ratings = hard; 
			}
			}
			//the above method allows to create rating by using if statement to print out ratings

			char addPuzzle(char aNameOfPuzzles, int theSizeOfPuzzles, int theNumOfPieces, char viewRatings, int theMissingPieces)
			{
			cout <<"enter information about the new puzzle";
			cout <<" Name Of puzzle is:"; cin>> aNameOfPuzzles; 
			cout <<" Size Of puzzle is:"; cin>> theSizeOfPuzzles;
			cout <<" Number Of pieces are:";cin>> theNumOfPieces; 
			cout <<" Number of missing pieces are:"; cin>>theMissingPieces;
			cout <<" this puzzle is rated at:";cin>> viewRatings; 
			}
			//creates a new jiasaw puzzle 

			return 0;
					
			}


and the new class
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
		#include "stdafx.h"
		#include <iostream>
		#include <iomanip>
		using namespace std;
		class puzzle (
		  protected:
			char nameOfPuzzles, ratings;
			int sizeOfPuzzles,numOfPieces, missingPieces;
		  public:
			void set_values(int size, int pieces, int missing , char name, char rate)
				(nameOfPuzzles = name; ratings = rate; sizeOfPuzzles = size; numOfPieces = pieces; missingPieces = missing;)
			
		  );

		class puzzle 1: public puzzle {
		  public:
			char newPuzzle()
			  { return (name,rate,size,pieces,missing); }
		  };
		int main () {
		  puzzle 1 puzz;
		  puzzle 1 puzz2;
		  puzz.set_values (ash puzz, meduim,9,4,4);
		  puzz2.set_values (jiasaw,easy,10,3,2);
		  cout << puzz.newPuzzle() << endl;
		  cout << puzz2.newPuzzle() << endl;
		  return 0;
		}


full errors so far
------ Build started: Project: puzzle, Configuration: Debug Win32 ------
Compiling...
puzzle 1.cpp
.\puzzle 1.cpp(6) : error C2059: syntax error : 'protected'
.\puzzle 1.cpp(9) : error C2059: syntax error : 'public'
.\puzzle 1.cpp(11) : error C2065: 'name' : undeclared identifier
.\puzzle 1.cpp(11) : error C2143: syntax error : missing ')' before ';'
.\puzzle 1.cpp(11) : error C2072: 'set_values' : initialization of a function
.\puzzle 1.cpp(11) : fatal error C1903: unable to recover from previous error(s); stopping compilation
puzzle .cpp
.\puzzle .cpp(82) : error C2059: syntax error : 'return'
.\puzzle .cpp(82) : error C2238: unexpected token(s) preceding ';'
.\puzzle .cpp(86) : fatal error C1004: unexpected end-of-file found
interface class.cpp
.\interface class.cpp(25) : error C3861: 'add_puzzle': identifier not found
.\interface class.cpp(28) : error C3861: 'remove_puzzle': identifier not found
.\interface class.cpp(31) : error C3861: 'view_list_of_puzzles': identifier not found
.\interface class.cpp(34) : error C3861: 'view_by_ratings': identifier not found
.\interface class.cpp(37) : error C3861: 'view_number_of_missing_pieces': identifier not found
Generating Code...
Build log was saved at "file://c:\Documents and Settings\Nix\My Documents\Visual Studio 2008\Projects\puzzle\puzzle\Debug\BuildLog.htm"
puzzle - 14 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
i don't know why the compiler is complaining about line 6 but I can see an error line11, at the end of teh line you have left out a ;

tbh
while I am still new at C++ so I may be wrong, I think line 11 is not needed, as this only needs declarations of the methods not implementation. The implementation happens in your class file, this looks like a main/header/class all mixed in one. So hopefully someone more experienced, and someone who hasn't been staring at java for the last 2 weeks will step in and help.
Last edited on
is this better


much better!
I'm not trying to pick on you, simply trying to help. So I apologize if you take offense.

In line 42 you have the brace at the right indentation level, but then line 43 the "}while (choice!= 27); " needs to be indented to the left. to line up with the "do{", keeping consistent indentation guides is important for yourself for debugging reasons(and is helpful for us to help you) and secondly it can also cause errors with conditionals and loops if your not careful.
1
2
3
4
5
6
7
8
9
class puzzle (
    protected:
	char nameOfPuzzles, ratings;
	int sizeOfPuzzles,numOfPieces, missingPieces;
    public:
	void set_values(int size, int pieces, int missing , char name, char rate)
		(nameOfPuzzles = name; ratings = rate; sizeOfPuzzles = size; numOfPieces = pieces; missingPieces = missing;)
			
		  );


your class is wrapped in () <---- I assume you mean to use {} this is the error on line 6.

1
2
3
4
5
6
7
8
9
class puzzle {
    protected:
	char nameOfPuzzles, ratings;
	int sizeOfPuzzles,numOfPieces, missingPieces;
    public:
	void set_values(int size, int pieces, int missing , char name, char rate)
		(nameOfPuzzles = name; ratings = rate; sizeOfPuzzles = size; numOfPieces = pieces; missingPieces = missing;)
			
		  };


ok in the class above that:
1
2
3
4
5
6
7
8
9
char addPuzzle(char aNameOfPuzzles, int theSizeOfPuzzles, int theNumOfPieces, char viewRatings, int theMissingPieces)
{
	cout <<"enter information about the new puzzle";
	cout <<" Name Of puzzle is:"; cin>> aNameOfPuzzles; 
	cout <<" Size Of puzzle is:"; cin>> theSizeOfPuzzles;
	cout <<" Number Of pieces are:";cin>> theNumOfPieces; 
	cout <<" Number of missing pieces are:"; cin>>theMissingPieces;
	cout <<" this puzzle is rated at:";cin>> viewRatings; 
}


this needs to return a char, or change it to ---> void addPuzzle(...)
and here you are doing the complete opposite:
1
2
3
4
5
6
7
8
void setMissingPieces(int theMissingPieces)
{	
	theMissingPieces = missingPieces;
}
void getMissingPieces(int theMissingPieces)
{
	return theMissingPieces;
}

you are returning values on void methods, you need to change the methods to whatever the values are. eg

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
char methodA()
{
    return 'a';
    // return a char
}

int method65()
{
   return 65;
   // return an int
}

double method45()
{
   double aDbl=44.98;
   return aDbl;
    // return a double
}

void printSomething( string messageToPrint )
{
    cout << messageToPrint << endl;
    // no return needed here... it's void.
}
Last edited on
you may want to consider validating as well.
http://www.cplusplus.com/forum/articles/6046/
Topic archived. No new replies allowed.