This is a very simple question that I cannot figure out.
I have three files Car.h
, Car.cpp
, and main.cpp
Car.h
class Car{
private:
public:
void printNumWheels();
Car() {};
~Car() {};
};
Car.cpp
#include <iostream>
#include "Car.h"
using namespace std;
void printNumWheels(){
cout << "four wheels";
}
main.cpp
#include "Car.h"
#include <iostream>
using namespace std;
int main(){
Car car;
car.printNumWheels();
}
When I run g++ car.cpp
I get the following error
Undefined symbols for architecture arm64:
"Car::printNumWheels()", referenced from:
_main in main-8cdc4f.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any ideas why that might be? Is there a different way I need to build the project? Or do I need to specify Car::printNumWheels() somewhere?
Thanks for the help