I've got a problem when declaring a class in a separate object file and then using it in the main function of another file:
main.cpp:
#include <helloclass.hpp>
using namespace std;
int main() {
    Hello hi;
    hi.hello();
    return 0;
}
helloclass.cpp:
#include <iostream>
using namespace std;
class Hello {
    public:
    void hello() {
        cout << "Hello world\n";
    }
    Hello() {}
};
helloclass.hpp:
class Hello {
    public:
    void hello();
    Hello();
};
Then I ran the following commands:
g++ -I. -c main.cpp
g++ -c helloclass.cpp
g++ -o main main.o helloclass.o
However, the last command gives the following output:
main.o: In function `main':
main.cpp:(.text+0x1f): undefined reference to `Hello::Hello()'
main.cpp:(.text+0x2b): undefined reference to `Hello::hello()'
collect2: error: ld returned 1 exit status
To me, it seems like I'm missing something pretty obvious. Does anyone know how to fix this?
 
    