I am trying to get the grasp on how to use header files in c++ but I keep getting this error:
Undefined symbols for architecture x86_64:
"myclass::myclass()", referenced from:
_main in main-06f616.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is the code that i am running. ( it is a very simple code, because again, I am trying to understand this.)
main.cpp:
#include <iostream>
#include "func.hpp"
using namespace std;
int main(){
myclass classone;
return 0;
}
func.hpp:
#ifndef func_H
#define func_H
class myclass {
public:
myclass();
};
#endif
func.cpp:
#include "func.hpp"
#include <iostream>
using namespace std;
myclass::myclass(){
cout << "I am a banana" << endl;
}