Using separate compilation

I have some errors popped up when attempting to compile the files. I'm using a header file, which is imported to the implementation file. The header file pretty much declares every variable and the implementation file is just me putting in the function definitions, etc

i defined the variable "Body" as a class in both the header file and implementation file without realizing it and the compiler points it out as an error of "redefinition" while attempting to compile.

Therefore, I eliminated the variable type "class" next to the variable "Body" in the implementation file and I get this error message


"error: expected unqualified-id before '{' token"
I don't really know what to do here and I'm not understanding why it's saying that.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Body. h



class Body
{

//code here

}


___________

Body.cpp



Body
{
// code here

}


this is a sample of what I recently did before I got this recent error message. I showed both the header file and the implementation file content or layout.

Any suggestions?
sorry. i forgot to include that the header file has the #ifndef....#endif

so its weird
On second thought, your Body.cpp looks fishy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Body {
  Body ();
  void foo ( int bar = 42 );
};

___________

// implementations

Body::Body ()
{
  // code of default constructor
}

void Body::foo( int bar )
{
  // code
}

Last edited on
Topic archived. No new replies allowed.