I have two .cpp files:
class.cpp
#include "stdafx.h"
#include "vehicles.h"
#include <iostream>
#include <time.h>
using MAP_GRID = vector<vector<string>>;
using namespace std;
void print_terrain(MAP_GRID);
void set_position(MAP_GRID &, int, int, vehicles::position, string);
void random_position(MAP_GRID &, int, string);
MAP_GRID create_terrain();
MAP_GRID MAP = create_terrain();
int _tmain(int argc, _TCHAR* argv[])
{
tanks t34(12, 0.5, 21,6);
srand(time(NULL));
//set_position(MAP, 5, 5, t34.pos,"[x]");
random_position(MAP, 12, "[o]");
print_terrain(MAP);
//[...]
}
and terrain.cpp
#include "stdafx.h"
#include <iostream>
#include <vector>
#include "vehicles.h"
#define MIN_SIZE 6
#define MAX_SIZE 15
using std::vector;
using std::string;
using MAP_GRID = vector<vector<string>>;
int global_size;
void set_position(MAP_GRID &MAP, int x, int y, vehicles::position &pos, string object)
{
if (x <= MAP.size() || y <= MAP.size())
if (MAP[x][y] != "[ ]")
std::cout << "\nPosition is occupied" << std::endl;
else
{
MAP[x][y] = object;
pos.x.push_back(x);
pos.y.push_back(y);
}
else
std::cout << "\Choose correct position" << std::endl;
}
//[...]
and also header file:
#include <iostream>
#include <vector>
using namespace std;
using std::vector;
using MAP_GRID = vector<vector<string>>;
void change_position(MAP_GRID &, int, int);
class vehicles{
protected:
double durability;
double velocity;
public:
vehicles(double d, double v) : durability(d), velocity(v) {}
~vehicles() {}
void drive();
void info() { cout << durability << " " << velocity << "\n"; }
struct position{
vector<int> x;
vector<int> y;
}pos;
};
class tanks:public vehicles{
private:
double damage;
public:
tanks(double dmg, double v, double d, int m) :vehicles(d, v), damage(dmg), ammo(m) {}
~tanks() {}
int ammo;
void shoot();
void info();
};
void tanks::shoot(){
if (ammo >= 0)
{
cout << "You deal " << damage << ". You have " << ammo << "ammo left.\n\n";
ammo-=1;
}
else
cout << "You don't have ammo\n\n";
}
void tanks::info(){
cout << "You velocity " << velocity << endl;
cout << "You durability " << durability << endl;
cout << "You damage " << damage << endl;
}
The compiler (Microsoft Visual Studio 2013) gives me these errors:
terrain.obj : error LNK2005: "public: void __thiscall tanks::info(void)" (?info#tanks##QAEXXZ) already defined in class.obj
terrain.obj : error LNK2005: "public: void __thiscall tanks::shoot(void)" (?shoot#tanks##QAEXXZ) already defined in class.obj
class.exe : fatal error LNK1169: one or more multiply defined symbols found
I know it's a common question about this error, but I'm trying remove it, without success.
Move tanks::shoot() and tanks::info() to terrain.cpp or class.cpp file. Or create vehicles.cpp and move definitions there.
You are including vehicles.h from two source files, so both object files (class.obj and terrain.obj) have tanks::shoot() and tanks::info() defined, but there should be only one definition, hence the error.
Related
I have 3 classes, GameObject, Building which inherits from GameObject, and PokemonCenter which inherits from Building. When I try to call a Building::ShowStatus() function in PokemonCenter I keep get a "invalid operands to binary expression" error.
Building.h
#ifndef BUILDING_H
#define BUILDING_H
#include "Point2D.h"
#include "GameObject.h"
class Building : public GameObject
{
private:
unsigned int pokemon_count;
public:
Building();
Building(char,int, Point2D);
void AddOnePokemon();
void RemoveOnePokemon();
void ShowStatus();
bool ShouldBeVisible();
};
#endif
Building.cpp
#include "Building.h"
#include "GameObject.h"
#include <iostream>
using namespace std;
Building::Building()
{
display_code = 'B';
location;
id_num = ' ';
state = '0';
pokemon_count = 0;
cout << "Building default constructed";
}
Building::Building(char in_code,int in_id, Point2D in_loc)
{
id_num = in_id;
location = in_loc;
display_code = in_code;
state = '0';
pokemon_count = 0;
cout << "Building constructed";
}
void Building::ShowStatus()
{
cout << "\"(" << pokemon_count << "\"pokemon is/are in this building";
}
PokemonCenter.h
#ifndef POKEMONCENTER_H
#define POKEMONCENTER_H
#include "Point2D.h"
#include "Building.h"
class PokemonCenter: public Building
{
private:
unsigned int stamina_capacity;
unsigned int num_stamina_points_remaining;
double dollar_cost_per_stamina_point;
PokemonCenter();
PokemonCenter(int,double,unsigned int, Point2D);
public:
bool HasStaminaPoints();
unsigned int GetNumStaminaPointsRemaining();
bool CanAffordStaminaPoints(unsigned int, Point2D);
double GetDollarCost(unsigned int);
unsigned int DistributeStamina(unsigned int);
bool Update();
void ShowStatus();
};
enum PokemonCenterStates
{
STAMINA_POINTS_AVAILABLE = 0,
NO_STAMINA_POINTS_AVAILABLE = 1
};
#endif
PokemonCenter.cpp
#include "PokemonCenter.h"
#include "Point2D.h"
#include "Building.h"
#include "GameObject.h"
#include <iostream>
using namespace std;
PokemonCenter::PokemonCenter()
{
id_num = ' ';
location;
display_code = 'C';
stamina_capacity = 100;
num_stamina_points_remaining = stamina_capacity;
dollar_cost_per_stamina_point = 5;
state = STAMINA_POINTS_AVAILABLE;
cout << "PokemonCenter default constructed";
}
PokemonCenter::PokemonCenter(int in_id, double stamina_cost, unsigned int stamina_cap, Point2D in_loc)
{
id_num = in_id;
location = in_loc;
dollar_cost_per_stamina_point = stamina_cost;
stamina_capacity = stamina_cap;
num_stamina_points_remaining = stamina_capacity;
state = STAMINA_POINTS_AVAILABLE;
cout << "PokemonCenter constructed";
}
void PokemonCenter::ShowStatus()
{
cout << "Pokemon Center Status: " << Building::ShowStatus() << endl;
}
The problem is that the return type of Building::ShowStatus() is void. operator<< is not defined between std::ostream and void. Hence, you can't use
cout << "Pokemon Center Status: " << Building::ShowStatus() << endl;
Change that to:
cout << "Pokemon Center Status: ";
Building::ShowStatus();
cout << endl;
This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 4 years ago.
My professor gave me two class header and .cpp files to build on. When I include these in main, they work fine. Whenever I just use his files, I get linker errors with clang and xcode.
Here's the error:
shannigan#mbp-007100 inheritance (master) $ make main
c++ main.cpp -o main
Undefined symbols for architecture x86_64:
"SavitchEmployees::SalariedEmployee::SalariedEmployee()", referenced from:
_main in main-0d7e27.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: *** [main] Error 1
Here's my main:
#include "employee.h"
#include "salariedemployee.h"
#include <string>
#include <cstdlib>
#include <iostream>
using namespace SavitchEmployees;
using namespace std;
int main() {
cout << "Do I run?" << endl;
SalariedEmployee sam;
return 0;
};
The header file for Employee:
//This is the header file employee.h.
//This is the interface for the class Employee.
//This is primarily intended to be used as a base class to derive
//classes for different kinds of employees.
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include <string>
using std::string;
namespace SavitchEmployees
{
class Employee
{
public:
Employee( );
Employee(const string& theName, const string& theSsn);
string getName( ) const;
string getSsn( ) const;
double getNetPay( ) const;
void setName(const string& newName);
void setSsn(const string& newSsn);
void setNetPay(double newNetPay);
void printCheck( ) const;
protected:
string name;
string ssn;
double netPay;
};
}//SavitchEmployees
#endif //EMPLOYEE_H
The CPP file for main:
//This is the file: employee.cpp
//This is the implementation for the class Employee.
//The interface for the class Employee is in the header file employee.h.
#include <string>
#include <cstdlib>
#include <iostream>
#include "employee.h"
using std::string;
using std::cout;
namespace SavitchEmployees
{
Employee::Employee( ) : name("No name yet"), ssn("No number yet"), netPay(0)
{
//deliberately empty
}
Employee::Employee(const string& theName, const string& theNumber)
: name(theName), ssn(theNumber), netPay(0)
{
//deliberately empty
}
string Employee::getName( ) const
{
return name;
}
string Employee::getSsn( ) const
{
return ssn;
}
double Employee::getNetPay( ) const
{
return netPay;
}
void Employee::setName(const string& newName)
{
name = newName;
}
void Employee::setSsn(const string& newSsn)
{
ssn = newSsn;
}
void Employee::setNetPay (double newNetPay)
{
netPay = newNetPay;
}
void Employee::printCheck( ) const
{
cout << "\nERROR: printCheck FUNCTION CALLED FOR AN \n"
<< "UNDIFFERENTIATED EMPLOYEE. Aborting the program.\n"
<< "Check with the author of the program about this bug.\n";
exit(1);
}
}//SavitchEmployees
SalariedEmployees header:
//This is the header file salariedemployee.h.
//This is the interface for the class SalariedEmployee.
#ifndef SALARIEDEMPLOYEE_H
#define SALARIEDEMPLOYEE_H
#include <string>
#include "employee.h"
using std::string;
namespace SavitchEmployees
{
class SalariedEmployee : public Employee
{
protected:
double salary;//weekly
public:
SalariedEmployee( );
SalariedEmployee (const string& theName, const string& theSsn,
double theWeeklySalary);
double getSalary( ) const;
void setSalary(double newSalary);
void printCheck( );
};
}//SavitchEmployees
#endif //SALARIEDEMPLOYEE_H
SalariedEmployee.cpp:
//This is the file salariedemployee.cpp
//This is the implementation for the class SalariedEmployee.
//The interface for the class SalariedEmployee is in
//the header file salariedemployee.h.
#include <iostream>
#include <string>
#include "salariedemployee.h"
using std::string;
using std::cout;
using std::endl;
namespace SavitchEmployees
{
SalariedEmployee::SalariedEmployee( ) : Employee( ), salary(0)
{
//deliberately empty
}
SalariedEmployee::SalariedEmployee(const string& newName, const string& newNumber,
double newWeeklyPay)
: Employee(newName, newNumber), salary(newWeeklyPay)
{
//deliberately empty
}
double SalariedEmployee::getSalary( ) const
{
return salary;
}
void SalariedEmployee::setSalary(double newSalary)
{
salary = newSalary;
}
void SalariedEmployee::printCheck( )
{
setNetPay(salary);
cout << "\n__________________________________________________\n";
cout << "Pay to the order of " << getName( ) << endl;
cout << "The sum of " << getNetPay( ) << " Dollars\n";
cout << "_________________________________________________\n";
cout << "Check Stub NOT NEGOTIABLE \n";
cout << "Employee Number: " << getSsn( ) << endl;
cout << "Salaried Employee. Regular Pay: "
<< salary << endl;
cout << "_________________________________________________\n";
}
}//SavitchEmployees
How can I get rid of these linker errors so I can focus on my actual code? Is there anything obvious wrong? The only thing I've changed was making the "private" variables protected.
I can't see the class named SalariedEmployee.
I think the main function should look like this.
int main() {
cout << "Do I run?" << endl;
Employee sam;
return 0;
};
You have to use Employee instead of SalariedEmployee
I have a problem with my program. I made a Graph class in C++, and now I want to sort it topologically. The thing is, my topological sort accepts any DirectedGraph, but when I want to give it a child (AdjacencyListDirectedUnweightedGraph for example), it refuses to convert. Here is my .hpps:
TopoSort.hpp:
#ifndef TOPOSORT_HPP
#define TOPOSORT_HPP
#include "../Graph.hpp"
#include "../DirectedGraph/AdjListUWDG.hpp"
#include "../DirectedGraph/DirectedGraph.hpp"
#include "../UnDirectedGraph/AdjListWUDG.hpp"
class TopoSort
{
protected:
std::vector<int> _sortedList;
std::vector<int> _KahnTopNodes;
public:
TopoSort();
~TopoSort();
void KahnSort(DirectedGraph &list);
void KahnSortTopNodes(DirectedGraph &list);
};
#endif
DirectedGraph.hpp
#ifndef DIRECTEDGRAPH_HPP
#define DIRECTEDGRAPH_HPP
#include <iostream>
#include <string>
#include <vector>
#include "../Graph.hpp"
class DirectedGraph
: public Graph
{
protected:
std::vector<int> _inDegree;
std::vector<int> _outDegree;
public:
DirectedGraph(){};
virtual ~DirectedGraph(){};
int inDegree(int a){return (_inDegree[a]);}
int outDegree(int a){return (_outDegree[a]);}
bool rangeCheck(int a, int b)
{
if (a >= _vertices || b >= _vertices || a == b)
{
std::cout << "The edge " << a << " - " << b << " is invalid." << std::endl;
return (false);
}
return (true);
}
};
#endif
AdjListDG.hpp
#ifndef ADJListDG_HPP
#define ADJListDG_HPP
#include <string>
#include <vector>
#include "DirectedGraph.hpp"
class AdjListDG
: public virtual DirectedGraph
{
protected:
std::vector<std::vector<std::pair<int, int> > > _adjList;
public:
virtual ~AdjListDG();
bool existsEdge(Edge);
bool existsEdge(int, int);
void putEdge(Edge);
void removeEdge(Edge);
int adjacentVertices(int);
bool areAdjacent(int, int);
};
#endif
AdjListUWDG.hpp
#ifndef AdjListUWDG_HPP
#define AdjListUWDG_HPP
#include <string>
#include <vector>
#include "AdjListDG.hpp"
class AdjListUWDG
: public virtual AdjListDG
{
public:
AdjListUWDG(std::string);
virtual ~AdjListUWDG();
};
#endif
And, my main.
#include <iostream>
#include <string>
#include <fstream>
#include "UnDirectedGraph/AdjListWUDG.hpp"
#include "UnDirectedGraph/AdjListUWUDG.hpp"
#include "UnDirectedGraph/AdjMatWUDG.hpp"
#include "UnDirectedGraph/AdjMatUWUDG.hpp"
#include "Assgn3/TopoSort.hpp"
int main(int argc, char** argv)
{
if (argc != 2)
{
std::cout << "Usage : ./graph FILENAME" << std::endl;
return(0);
}
std::string filename = argv[1];
AdjListWUDG gr(filename);
TopoSort tsort;
std::ofstream fichier("results.txt", std::ios::out | std::ios::trunc);
if(fichier)
{
if (gr.existsEdge(1, 2))
fichier << "1 - 2 exist" << std::endl;
fichier << "numedge == " << gr.numEdges() << std::endl;
fichier << "adjver 1 == " << gr.adjacentVertices(1) << std::endl;
fichier << "adj 1 2 == " << gr.areAdjacent(1,2) << std::endl;
fichier << "adj 1 0 == " << gr.areAdjacent(1,0) << std::endl;
fichier << "adj 0 2 == " << gr.areAdjacent(0,2) << std::endl;
}
DirectedGraph * gr2 = &gr;
tsort.KahnSort(*gr2);
}
That's it ! I'm sorry if it looks obvious or something, I just can't see what's the problem. Also tried dynamic and static casts, no success. thanks in advance !
EDIT :
I was stupid. tried to cast for a reference, instead of an object itself...
static_cast instead of static_cast
Sorry for that useless post !
Casting to a reference instead of the object itself, that was stupid, sorry !
I'm attempting to practice some coding in my free time (combining a number of different interests of mine to help keep myself engaged) and I've encountered a odd error that I can't find the answer to. I have 4 files that I'm working with, two header files, one class definition file and a main file. I'm fairly confident I'm not including the Dice.h file more then once (however that is where the error points to and I'm not sure anymore, hence this question). What have I bungled here to produce these errors?
The error codes
Error 3 error LNK1169: one or more multiply defined symbols found (file path trimmed)
Error 2 error LNK2005: "int __cdecl dice(int,int)" (?dice##YAHHH#Z) already defined in Creature.obj (file path trimmed)
The filepath: c:\Users\Username\documents\visual studio2010\Projects\RPGTest\RPGTest\RPGTest.(error 3 referenced a .exe file, error 2 referenced a .obj file).
The code itself:
Dice.h
#ifndef SET_DICE_H_
#define SET_DICE_H_
#include <iomanip>
#include <iostream>
#include <stdlib.h>
using namespace std;
int dice(int number, int sides){
int total=0, dice;
srand(time(NULL));
int results=0;
do {
dice = rand()%sides+1;
total+=dice;
number--;
} while (number > 0);
results = total;
return results;
}
#endif
Creature.h
#ifndef CREATURE_H_
#define CREATURE_H_
#include <iomanip>
#include <iostream>
#include "Dice.h"
using namespace std;
class Creature {
public:
Creature(int,int,int,int,int,int,int,int,int,int,int,int);
void set_hp();
void set_saves();
void set_ac();
void set_bab();
void set_name();
void update_hp(int);
void update_ac(int);
void update_fsave(int);
void update_rsave(int);
void update_wsave(int);
int get_ac();
int get_hp();
int get_fsave();
int get_rsave();
int get_wsave();
int get_bonus(int);
int get_bab();
string get_name();
private:
int strength, dexterity, constitution, intellegence, wisdom, charisma;
int bab, fbsave, rbsave, wbsave;
int hdnum, hdsize;
int hp, fsave, rsave, wsave, ac;
string name;
};
#endif
Creature.cpp
#include "Creature.h"
#include <math.h>
#include <iostream>
using namespace std;
Creature::Creature(int strength,int dexterity,int constitution,
int intellegence,int wisdom,int charisma,int bab,int fbsave,
int rbsave,int wbsave,int hdnum,int hdsize){
strength = strength;
dexterity = dexterity;
constitution = constitution;
intellegence = intellegence;
wisdom = wisdom;
charisma = charisma;
bab = bab;
fbsave = fbsave;
rbsave = rbsave;
wbsave = wbsave;
hdnum = hdnum;
hdsize = hdsize;
}
int Creature::get_bonus(int stat){
int bonus = floor((double(stat)-10)/2);
return bonus;
}
void Creature::set_ac(){
ac=10+get_bonus(dexterity);
}
void Creature::set_hp(){
hp = dice(hdnum,hdsize) + get_bonus(constitution)*hdnum;
}
void Creature::set_saves(){
fsave = fbsave + get_bonus(constitution);
rsave = rbsave + get_bonus(dexterity);
wsave = wbsave + get_bonus(wisdom);
}
void Creature::set_bab(){
bab = hdnum;
}
void Creature::set_name(){
cout << "Please enter a name for this creature: ";
cout << "\nSorry! I don't work yet!";
cout << "\nInstead all creatures are named Larry!\n";
name = "Larry!";
}
void Creature::update_hp(int input){
hp = hp + input;
}
void Creature::update_fsave(int input){
fsave = fsave+input;
}
void Creature::update_rsave(int input){
rsave = rsave+input;
}
void Creature::update_wsave(int input){
wsave = wsave+input;
}
void Creature::update_ac(int input){
ac = ac+input;
}
int Creature::get_ac(){
return ac;
}
int Creature::get_hp(){
return hp;
}
int Creature::get_fsave(){
return fsave;
}
int Creature::get_rsave(){
return rsave;
}
int Creature::get_wsave(){
return wsave;
}
int Creature::get_bab(){
return bab;
}
RPGTest.cpp
#include "Creature.h"
#include <math.h>
//#include "Dice.h"
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int str = dice(3,6), dex = dice(3,6), con = dice(3,6), intel = dice(3,6), wis = dice(3,6), cha = dice(3,6);
int fbs = dice(1,6), rbs = dice(1,6), wbs = dice(1,6);
int hdn = dice(1,10), hds = 8, bab = dice(1,8);
cout << "Welcome to RPG Creature Tester v0.1\n";
cout << "This .exe file is meant to test the creature class functions and definitions.\n";
cout << "This will be done by randomly generating and displaying a creature.\n";
cout << "What you don't see right now is the random generation of a creature.\n";
cout << "Once it's finished, the \'statsheet\' will be shown.\n";
cout << "Cheers!\n\n";
Creature potato (str, dex, con, intel, wis, cha, bab, fbs, rbs, wbs, hdn, hds);
potato.set_ac();
potato.set_hp();
potato.set_name();
potato.set_saves();
cout << "OUTPUT BRICK YAY\n";
cout << "Str: " << str << endl;
cout << "HP: " << potato.get_hp() << " AC: " << potato.get_ac() << " Fort/Reflex/Will Save: " << potato.get_fsave() << "/" << potato.get_rsave() << "/" << potato.get_wsave();
return 0;
}
Since I'm mainly self-taught I'm happy for any other advice but my main issue is that I'm not sure why I'm getting the "multiple" definition error. I did some research into other questions with similar error messages but I didn't see anything that immediately jumped out at me as "the answer".
Thanks all!
C++ works by compiling single translation units and then linking them together.
This means that each source file gets compiled on its own. Since the #include directive basically inserts all the code included, in your situation you end up having multiple translation units which define
int dice(int number, int sides) {
...
}
Compilation goes through fine but, when linking, multiple definition of this function are found so this generates the error.
To solve this problem you have two ways:
declare int dice(int, int) in a header file but define (implement it) in a source file
keep the definition as it is but prepend static to it. This tells the compiler that each translation unit will get its own dice method. This solution, although tempting, leads to binary size increase since you will have multiple implementation of the same method
I have a project that consists of 2 CPP files (main.cpp and Car.cpp) and a header file (Car.h). The program is meant to allow a user to enter the model, make, and speed of a car and displays the modified speed. My issue is that when I compile the project, I receive a "1 unresolved externals" issue like so:
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall Car::Car(void)" (??0Car##QAE#XZ) referenced in function _main
1>C:\Users\Shaidi\Desktop\Classes\CIST 2362\Projects\main\Debug\main.exe : fatal error LNK1120: 1 unresolved externals
Here is the main.cpp file:
// main.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "Car.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
string make;
int model, speed;
Car c;
//user input and assignment for make, model, and speed
cout << "Enter the make of the car: " <<endl;
cin >> make;
c.setMake(make);
cout << "Enter the model of the car: " <<endl;
cin >> model;
c.setYearModel(model);
cout << "Enter the speed of the car: " <<endl;
cin >> speed;
c.setSpeed(speed);
//print make and model
cout << "Car make: " << c.getMake() <<endl;
cout << "Car model: " << c.getYearModel() << endl;
cout << "Car speed: " << c.getSpeed() <<endl;
//loops to calculate and print acceleration and braking
for (int i = 0; i < 5; i ++){
cout << "Car speed after acceleration: " <<c.accelerate() <<endl;
}
for (int i = 0; i < 5; i ++){
cout << "Car speed after braking: " <<c.brake() <<endl;
}
return 0;
} //end main
Here is the Car.cpp file:
// Car.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "Car.h"
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;
Car::Car(int y, string m)
{
string make = m;
int year = y;
speed = 0;
}
void Car::setYearModel(int y)
{
yearModel = y;
}
void Car::setSpeed(int s)
{
if (s >= 0){
speed = s;
} else {
cout << "Invalid speed";
exit(EXIT_FAILURE);
}
}
void Car::setMake(string m)
{
make = m;
}
int Car::getYearModel()
{
return yearModel;
}
int Car::getSpeed()
{
return speed;
}
string Car::getMake()
{
return make;
}
int Car::accelerate()
{
return speed + 5;
}
int Car::brake()
{
return speed - 5;
}
And here is the Car.h file:
#ifndef CAR_H
#define CAR_H
#include <string>
using namespace std;
class Car
{
private:
std::string make;
int yearModel;
int speed;
public:
Car();
Car(int, std::string);
void setYearModel(int);
void setSpeed(int);
void setMake(std::string);
int getYearModel() ;
int getSpeed() ;
int accelerate() ;
int brake() ;
std::string getMake() ;
};
#endif // CAR_H
You miss the implementation of default constructor of Car().
class Car
{
public:
// There is no implementation.
Car();
}
You've declared Car::Car() but never defined it. Either add a definition to the .cpp file, or remove the declaration from the header.
For example:
Car::Car()
{
}
It looks like you have defined the default constructor for car but have not implemented it. Then you declared a variable of type car which would require it to be implemented. Adding the code that Kerrek has above to the .cpp file should do the trick :)