Header files and Implementation files

Hello,
I am very new to C++ and this weeks class we had to do 5 files: Main.cpp Circle.cpp Square.cpp and then circle.h and square.h

I was able to get the 5 files, and I believe all the code is written for each file, but I am now getting an error:
error: ld returned 1 exit status.

I believe I am also suppose to put #include "circle.h" and #include "square.h" near the top, but it errors on me when I do. Will this make a difference?
Thank you,

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
  #include <iostream>


using namespace std;


//define your function here
class Circle
{
double radius;
public:
    Circle(double r) {radius = r; }
    double circum() {return 2*radius*3.14;}
};

class Square {
float width, height;
public:
    Square(float x, float y) : width (x), height(y) {}
    float area(void) {return width*height; }

int main()
    {
Circle r();
Square s();

    cout<<"Circle: ";
    cout<<"Radius: ";


    cout<<"Square:";
    cout<<"int x, int y: ";

    return 0;
   }

};
Where does the Square class ends? I.e. there is a closing }; missing.
I am now getting an error:
error: ld returned 1 exit status.

That's a linker error. Presumably, your linker will be telling you more than just that - there will be more detailed information about why it's failing to link. It's always better to share the information you have with us, rather than withholding it, so in future, please post the full error messages you have.

You've defined your main function to be a member of Square. This means that you've defined a method Square::main(), but nowhere in your code do you have an actual main() function.
Topic archived. No new replies allowed.