[URGENT] HELP NEEDED FOR CLASS IN C++

Thread Starter

NiCeBoY

Joined Aug 20, 2008
59
hello,
i got an assignment which consist of 3 questions.
i was able to do first and second question but the third one i am getting some problems..

i am posting the code and question as image so as they don't appear on search engines as its for uni things...

The answer is a .cpp file. I modified the filename to .cpp.txt because the forum here does not allow upload of .cpp file.

only these part i think needs to modify:

first:
Quote:
// --------------------needs mods----

Circle_Shape(){};
Circle_Shape(Point c, double s){
centre = c;
size = s;
};

// ------------
second :

Quote:
// -----------------needs mods-------

Rec_Shape(){};
Rec_Shape(Point w, double s){
width = w;
size = s;
};

// ------------
Third

Quote:
cout << rect.area() << endl;
cout << rect.perimeter() << endl;
cout << circ.area() << endl;
cout << circ.perimeter() << endl;
I really need to get this working urgently...

Please when replying don't post the whole code directly on the forum...

send as attachment or just part which you modified...


Thank you very much in advance for your help...
 

Attachments

Last edited:

Mark44

Joined Nov 26, 2007
628
When you say it isn't working, what do you mean? Are you getting compiler or linker errors, or are you getting no errors but your program isn't producing any results or is producing incorrect results?
 

Thread Starter

NiCeBoY

Joined Aug 20, 2008
59
i am getting errors,
here are the errors:

1>------ Build started: Project: Qu 3, Configuration: Debug Win32 ------
1>Compiling...
1>Qu 3.cpp
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(83) : error C2504: 'TwoD_Shape' : base class undefined
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(89) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(89) : warning C4183: 'Circle_Shape': missing return type; assumed to be a member function returning 'int'
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(90) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(93) : warning C4183: 'Circle_Shape': missing return type; assumed to be a member function returning 'int'
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(91) : error C2065: 'centre' : undeclared identifier
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(92) : error C2065: 'size' : undeclared identifier
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(99) : error C2059: syntax error : '='
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(99) : error C2065: 'size' : undeclared identifier
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(99) : error C2065: 'size' : undeclared identifier
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(99) : error C2143: syntax error : missing ';' before ')'
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(99) : error C2143: syntax error : missing ';' before ')'
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(104) : error C2059: syntax error : '='
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(104) : error C2100: illegal indirection
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(104) : error C2065: 'size' : undeclared identifier
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(104) : error C2143: syntax error : missing ';' before ')'
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(104) : error C2143: syntax error : missing ';' before ')'
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(109) : error C2504: 'TwoD_Shape' : base class undefined
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(115) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(115) : warning C4183: 'Rec_Shape': missing return type; assumed to be a member function returning 'int'
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(116) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(119) : warning C4183: 'Rec_Shape': missing return type; assumed to be a member function returning 'int'
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(117) : error C2440: '=' : cannot convert from 'Point' to 'double'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(118) : error C2065: 'size' : undeclared identifier
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(128) : error C2065: 'size' : undeclared identifier
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(133) : error C2065: 'size' : undeclared identifier
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(139) : error C2661: 'Rectangle::Rectangle' : no overloaded function takes 3 arguments
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(147) : error C2228: left of '.area' must have class/struct/union
1>d:\idm\compressed\qu 3\qu 3\qu 3\qu 3.cpp(148) : error C2228: left of '.perimeter' must have class/struct/union
1>Build log was saved at "file://d:\IDM\Compressed\Qu 3\Qu 3\Qu 3\Debug\BuildLog.htm"
1>Qu 3 - 25 error(s), 4 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
thanks
 

Mark44

Joined Nov 26, 2007
628
OK, let's take a look at the first five errors (I'm going to skip the warnings for now).
Every one of these is a compiler error or warning, so the compiler is telling you that you did something wrong for each one. I'm going to omit the first part of the error message.

1. Line 83 - error C2504: 'TwoD_Shape' : base class undefined
In your code you have a Two_dim_shape, but you changed this to TwoD_Shape. Change all occurrences of TwoD_Shape to Two_dim_shape.

2. Line 89 - error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
I think this one will go away after you fix the first error.

3. Line 90 - error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Same as previous error.

4. Line 91 - error C2065: 'centre' : undeclared identifier
This too will go away once you inherit the Circle class from the correct base class, Two_dim_shape.
5. Line 92 - error C2065: 'size' : undeclared identifier
Same as above.

Make those changes, and recompile. You should get a lot fewer errrors after you fix the problem of TwoD_Shape declared vs. Two_dim_shape used.

Mark
 
Top