C++ error, Undefined reference class

You need to link both main.o and class.o into your executable. The exact command depends on your compiler and OS. For g++ the command would look something like

g++ -o main main.cpp class.cpp