Error LNK2019: unresolved external symbol

This is my error output:
1>CustomerSetnGet.obj : error LNK2019: unresolved external symbol "public: __thiscall Car::Car(void)" (??0Car@@QAE@XZ) referenced in function "public: __thiscall Customer::Customer(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (??0Customer@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0H@Z)


Below is my code:

//Car.h

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;

#ifndef Car_H
#define Car_H

class Car
{
private:
string plate,model,color;
double capacity;
int year;

public:
Car(string plate, string model, string color, double capacity,int year);
Car();

string getPlate() const;
string getModel()const;
string getColor() const;
double getCapacity() const;
int getYear() const;

void setPlate(string plate);
void setModel(string model);
void setColor(string color);
void setCapacity(double capacity);
void setYear(int year);
};


#endif

//Customer.h

#include <string>
#include "Car.h"

using namespace std;

#ifndef Customer_H
#define Customer_H

class Customer
{
private:
string name,ic;
int rg_no;
Car car;

public:
Customer(string name, string ic,int rg_no);

string getName();
string getIc();
int getRg_no();

void setName(string name);
void setIc(string ic);
void setRg_no(int rg_no);
};

#endif

//Customer.cpp

#include "stdafx.h"
#include "Customer.h"

Customer::Customer(string name, string ic,int rg_no)
{
this->name=name;
this->ic=ic;
this->rg_no=rg_no;
}

string Customer::getName()
{
return name;
}

string Customer::getIc()
{
return ic;
}

int Customer::getRg_no()
{
return rg_no;
}
void Customer::setName( string name)
{
this->name = name;
}
void Customer::setIc( string ic)
{
this->ic = ic;
}
void Customer::setRg_no(int rg_no)
{
this->rg_no = rg_no;
}

Car.cpp

#include "stdafx.h"
#include "Car.h"

Car::Car(string plate, string model, string color, double capacity, int year)
{
this->plate=plate;
this->model=model;
this->color=color;
this->capacity=capacity;
this->year=year;
}

string Car::getPlate() const
{
return plate;
}

string Car::getModel() const
{
return model;
}

string Car::getColor() const
{
return color;
}

double Car::getCapacity() const
{
return capacity;
}

int Car::getYear()const
{
return year;
}

void Car::setPlate(string plate)
{

this->plate = plate;
}

void Car::setModel(string model)
{

this->model = model;
}
void Car::setColor(string color)
{

this->color = color;
}
void Car::setCapacity(double capacity)
{

this->capacity = capacity;
}

void Car::setYear( int year)
{

this->plate = plate;
}


//main.cpp


#include "stdafx.h"
#include "Customer.h"
#include "Car.h"

void mainMenu();
void Registration();

string name,ic,plate,model,color;
double capacity;
int rg_no,year;

//int current=0;
//int i=0;

int _tmain(int argc, _TCHAR* argv[])
{
mainMenu();
return 0;
}

void mainMenu()
{
int choice;

cout<<"====Road Transport Department Menu====\n";
cout<<"\t1. Registration\n";
cout<<"\t2. Modification\n";
cout<<"\t3. Delete\n";
cout<<"\t4. View\n";
cout<<"\t5. Exit\n\n";

cout<<"Your choice: ";
cin>>choice;

while(choice != 1 || choice != 2 || choice != 3 || choice != 4 || choice != 5)
{
cout<<" ERROR! Please enter valid value!";
cin>> choice;
}

if(choice==1)
{
system("cls");
Registration();
}

if(choice==2)
{

}

if(choice==3)
{

}

if(choice==4)
{

}

if(choice==5)
{
cout<<"=====THANK YOU=====\n\n";
}

}

void Registration()
{
int choice;
char choice2;


//rg_no=i+1;

cout<<"\n=========REGISTRATION FORM=========\n\n";

cout<<"\tRegister No: "<<rg_no<<endl;
cout<<"\tName: ";
cin>>name;
cout<<"\tIC Number: ";
cin>>ic;
cout<<"\tPlate Number: ";
cin>>plate;
cout<<"\tCar Model: ";
cin>>model;
cout<<"\tEngine Capacity: ";
cin>>capacity;
cout<<"\tColor: ";
cin>>color;
cout<<"\tYear Manufactured: ";
cin>>year;
cout<<"\nComfirm submission?"<<endl;
cout<<"1.Yes\n2.Refresh\n3.Exit\nYour Choice: ";
cin>>choice;

if(choice == 1)
{
Customer ctmr(name, ic,rg_no);
Car car(plate, model, color, capacity, year);

//i++;

cout<<"Return to Main menu?[y/n] ";
cin>> choice2;

if(choice2 == 'y'||choice2 == 'Y')
{
system("cls");
mainMenu();
}

else
{
cout<<"Thank You for registration";
}
}

else if(choice == 2)
{
system("cls");
Registration();
}

else
cout<<"\n*Registration Cancelled!*\n";

}

Thanks you in advance.
Last edited on
You do not have Car::Car constructor implemented.
Topic archived. No new replies allowed.