My code is this:
Main.cpp
#include <iostream>
#include "Sally.hpp"
using namespace std;
int main() {
Sally so;
}
//i only wanted to define an object.
Sally.cpp
#include <iostream>
#include "Sally.hpp"
using namespace std;
Sally::Sally() // this part is the constructor
{
cout << "Hi. This is the constructo." << endl;
}
Sally::~Sally()
{
cout<< "what's up" << endl; //deconstructor
}
Sally.hpp
#ifndef SALLY_H
#define SALLY_H
class Sally //just defined a class
{
private:
public:
Sally(); // just declared a constructor. remember constructor is just the same name as class
~Sally(); // just declared a deconstructor
};
#endif
And I get the error message:
main Undefined symbols for architecture x86_64: "Sally::Sally()", referenced from: _main in main-247326.o "Sally::~Sally()", referenced from: _main in main-247326.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have no idea why it does this, but this always happens when I try to link class files to main.cpp. I haven't been programming for a while, but i'm not sure if there is something wrong with my terminal (like I need to install something) or I messed up somewhere.