I run my code on a Windows Machine and Online compilers, it works. But on my Mac it doesn't.
The following is my code:
#include "T7.h"
using namespace std;
int main()
{
Car myCarObject1; // create a car object named myCarObject1 with default constructor.
Car speedster("speedster", 10); // creating a car object named speedster with a different constructor.
while (speedster.hasFuel()) // while we have fuel,
{
speedster.drive(); // keep driving!
}
speedster.drive(); // can�t drive - ran out of fuel.
return 0;
}
The following is the error in the console
Undefined symbols for architecture x86_64:
"Car::drive()", referenced from:
_main in main-30909e.o
"Car::hasFuel()", referenced from:
_main in main-30909e.o
"Car::Car(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int)", referenced from:
_main in main-30909e.o
"Car::Car()", referenced from:
_main in main-30909e.o
"Car::~Car()", referenced from:
_main in main-30909e.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)