1

I have three files: class.h with declaration of class; class.cpp with definition of class and main.cpp where I call class. How can I compile it?

I've tried

g++ main.cpp class.h class.cpp

but I have a lot of errors like "not declared in this copy or library doesn't include", but I actually included this libraries in class.h and inclued class.h in main.cpp. I mean when I compile it in Visual Studio all is working, but in Linux it isn't.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
rastr__
  • 23
  • 4
  • Compiling the header file will create a pre-compiled header, which might not be what you want to do. Files that use things referenced in the header file need to `#include "class.h"`. Then, just compile those files. `g++ main.cpp class.cpp` might be enough. – jxh Oct 10 '21 at 20:10

0 Answers0