Error when Compiling project

Hi everyone, I am a noob in c++.
I have been studying ths topic called Objects and Classes
from the book: Introduction to Programming with C++ by Y. Daniel Liang

I started typing an example project from the book in my Dev C++ compiler.
I wrote everything exactly as printed in the book, but i just get a bunch
of errors that i don't even know what they mean.

I will post the files code then the Compiling Errors as last.

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

//This is the header file Circle.h

class Circle ( ) { 
   
    public:
   	// The radious of this circle
   	double radious;
   	
   	// Here is construct a default cirlce object
   	Circle ( );
   	
   	// Construct a circle object
   	Circle(double);
   	
   	//Return the area of this circle
   	double getArea( );
};

// Circle.cpp this is file 2 from the Project

 #include "Circle.h"
   
    // Construct a default circle object
    Circle::Circle ( ) {
	
    radious = 1;
}
    
    // Constructs a circle object
    Circle::Circle ( doble newRadious ) {
    	
    radious = newRadious;
	}
	
	// Return the area of this circle
	double Circle::getArea ( ) {
		
	return raidious * radious * 3.14159;
	}

// This last file will test the whole project TestCircle.cpp

#include <iostream>
    #include "Circle.h"
    using namespace std;
    
    int main ( ) { 
    
    Circle circle1;
    Circle circle2 ( 5.0 );
    
    cout << " The are of the circle of radious " << circle1.radious << " is " << circle1.getArea ( ) << endl;
    cout << " The are of the circle of radious " << circle2.radious << " is " << circle2.getArea ( ) << endl;
    
    // Modify the circle radious
    circle2.radious = 100;
    
    cout << " The area of the  circle of radious " << circle2.radious << " is " << circle2.getArea ( ) << endl;
    
    return 0;
	}
Last edited on
All of these are three individual files. They are a project after all.

// This are the errors i get:

3 0 C:\Users\KingReno\Documents\Programming I\Circle.cpp In file included from Circle.cpp

5 20 C:\Users\KingReno\Documents\Programming I\Circle.h [Error] expected unqualified-id before ')' token

6 22 C:\Users\KingReno\Documents\Programming I\Circle.cpp [Error] invalid use of incomplete type 'class Circle'

3 0 C:\Users\KingReno\Documents\Programming I\Circle.cpp In file included from Circle.cpp

5 11 C:\Users\KingReno\Documents\Programming I\Circle.h [Error] forward declaration of 'class Circle'

12 20 C:\Users\KingReno\Documents\Programming I\Circle.cpp [Error] expected constructor, destructor, or type conversion before '(' token

18 27 C:\Users\KingReno\Documents\Programming I\Circle.cpp [Error] invalid use of incomplete type 'class Circle'

3 0 C:\Users\KingReno\Documents\Programming I\Circle.cpp In file included from Circle.cpp

5 11 C:\Users\KingReno\Documents\Programming I\Circle.h [Error] forward declaration of 'class Circle'

28 C:\Users\KingReno\Documents\Programming I\Makefile.win recipe for target 'Circle.o' failed
1) At line 4 in your OP: You shouldn't have the parentheses in that class definition. That's probably causing most of your compilation errors.

2) Line 31: That's not how you spell double.

3) Why are you making your data member public? Encapsulation is one of the fundamental principles of OOP; by making radious public, you're violating that.

4) Line 27: In your constructor, it's better to use an initialisation list to initialise data members, rather than assigning values in the body of the constructor. You may not have come across this yet in your learning.

5) In general, you've misspelled "radius". Not a huge problem in itself, however...

6) At line 39, you haven't spelled it the same way as in your class definition, and that will cause a compilation error.
Thank you MikeyBoy, I appreciate your help. I now why my mates tell me not to stay until morning studying. I didn't realize those parentheses at all nor the spelling errors. Class declaration should not have parentheses, only default objects or ther objectf of the same class or anonymous objects.

Thank you alot sir.
You're welcome! Glad it helped.
Topic archived. No new replies allowed.