I'm trying to learn object-oriented programming in C++, but I'm having trouble compiling the following simplified example:
TestBank.cpp:
#include <iostream>
#include "Bank.h"
int main()
{
Bank deBank;
}
Bank.h:
#ifndef BANK
#define BANK
class Bank
{
public:
Bank();
};
#endif
Bank.cpp:
#include "Bank.h"
Bank::Bank() {
//
}
When I'm trying to execute make TestBank
, I get the following error:
c++ TestBank.cpp -o TestBank
Undefined symbols for architecture x86_64:
"Bank::Bank()", referenced from:
_main in TestBank-480209.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [TestBank] Error 1
What is causing this behaviour? It seems like Bank.cpp
is never included. How can I fix this?