Headers and source file
Jun 18, 2014 at 8:05am UTC
I am trying to learn how to use headers and source file. I have been reading this
http://www.cplusplus.com/forum/articles/10627/. My error is:
Error 1 error LNK2019: unresolved external symbol "public: __thiscall Car::Car(void)" (??0Car@@QAE@XZ) referenced in function _main C:\Users\George\documents\visual studio 2013\Projects\Chapter13\Chapter13\main.obj Chapter13
also
Error 2 error LNK1120: 1 unresolved externals C:\Users\George\documents\visual studio 2013\Projects\Chapter13\Debug\Chapter13.exe 1 1 Chapter13
Car.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#ifndef _Car_
#define _Car_
using namespace std;
#include <string>
class Car
{
private :
int yearModel, speed;
string carMake;
public :
int m_yearModel(){ return yearModel; }
int m_speed(){ return speed; }
string m_carMake(){ return carMake; }
Car(int , string);
Car();
~Car();
};
#endif
Car.cpp
1 2 3 4 5 6 7 8 9 10 11
#include "Car.h"
Car::Car(int year, string Make)
{
yearModel = year;
carMake = Make;
speed = 0;
}
Car::~Car()
{
}
main.cpp
1 2 3 4 5 6 7 8 9
#include <iostream>
#include "Car.h"
using namespace std;
int main()
{
Car a;
return 0;
}
thank you
Jun 18, 2014 at 8:07am UTC
You did not implement the constructor on line 17 in Car.h
Jun 18, 2014 at 8:13am UTC
WOW i am so bad. I fixed it and it works.
Thank you.
Topic archived. No new replies allowed.