Hello everyone, I am not sure if this is the right section for my question.
I'm sure you've seen a million questions like mine, but unfortunately I have the following problem.
I tried to write a program in C++ and when I try to run, it comes out the following message: "UNDEFINED REFERENCE TO CLASS" and I cannot compile.
The curious thing is that this problem appears only when I try to compile and run for the FIRST time, because when I close the editor and I reopen it, it works successfully.
So I think this problem has something to do with my compiler, therefore I would ask which compiler I should use for C++, Windows 64.
Or, maybe, if you think the problem is referred to the code, I could link my project folder, if you need.
Thanks to everyone guys!
class provaClass
{
public:
provaClass();
virtual ~provaClass();
void print();
protected:
private:
};
#endif // PROVACLASS_H
The error messages, referred to the main, are:
undefined reference to `provaClass::provaClass()'
undefined reference to `provaClass::print()'
undefined reference to `provaClass::~provaClass()'
undefined reference to `provaClass::~provaClass()'
Hello everyone! I think to understand why I had this problem.
I am using CodeBlocks 13.12 and when I create a class, there is a default setting that says
"Header and implementation files shall always be in the same folder"
This setting puts in the project folder the .h/.hpp and the .cpp files together, but maybe the compiler is not able to find them.
So the right way to solve the problem is
TO UNCHECK THE BOX "HEADER AND IMPLEMENTATION FILES SHALL ALWAYS BE IN THE SAME FOLDER",
so in the project folder two folders will be created:
1_ include (folder) in which there will be the ..hpp file
2_ src (folder) in which there will be the .cpp file
And in this ways, it works finally!