0

I have a large amount of code, so I have tried to only include the relevant parts of the code here

My cpp files compiled with no problems when they were included in another cpp file.

I have another file called. This compiled fine before, until I tried to include the files above in

I get undefined reference errors, even though they were defined in the cpp file

What is going on? Is there a linkage error? Do I need to make changes in the makefile?

csx
  • 1
  • 1
  • 1
  • 4
  • You're missing a semicolon after the class. – Biffen Nov 20 '14 at 21:01
  • oh, the actual class has a semicolon after it. I just forgot to include it when I tried to modify its contents to post it in the question – csx Nov 20 '14 at 21:04
  • OK. What other differences are there? – Biffen Nov 20 '14 at 21:04
  • Why are you using `Asp::Asp(input)` ? Shouldn't that be either `Asp* asp = new Asp(input)` (because of your using clause) or a full resolved `ASP:Asp* asp = ASP::Asp(input)` including the namespace ? – WhozCraig Nov 20 '14 at 21:19
  • @WhozCraig, why would `new ASp::ASp(input);` be considered an `int*`? – R Sahu Nov 20 '14 at 21:30

1 Answers1

0

Using

ASp* asp = new ASp(input);

works for me. Not sure why using

ASp* asp = new ASp::ASp(input);

is a problem. Need to dig further to find out.

Update

The same problem was addressed at using declarations in main (C++). The tool chain for that question is MS Visual Studio. The answers there point out the same problem but there is no explanation of why new Asp::Asp(input); would be of type int*. The error message reported by the OP appears to be a g++ specific error message.

Community
  • 1
  • 1
R Sahu
  • 204,454
  • 14
  • 159
  • 270