암만 검색을 해봐도


C언어 같은 경우에는 함수 빠진거 있나 보고 함수 넣어주면 된다는데


C++은 아무래도 클래스 위주로 쓰니깐

LNK1120이랑 2019조합 한방 맛보니까 정신을 못차리겠음


먼저 코드부터 올릴게






#include <iostream>

#include <cstdlib>

#include <string>

#include <crtdbg.h>

using namespace std;


class Vehicle{

bool ignite;

public:

Vehicle();

Vehicle(bool ignite);

~Vehicle();

};

Vehicle::Vehicle(bool ignite)

{

if (ignite = true)

{

cout << "The Vehicle can start ignite." << endl;

}

else

{

cout << "The Vehicle can't start ignite." << endl;

}

}

Vehicle::~Vehicle()

{

cout << "Get rid of Vehicle Class" << endl;

}


class Car{

public:

int increment;

int decrement;

char *color;

int engine;

int gear;

int speed;

Car();

~Car();

Car(int inc, int dec)

{

inc = increment;

speed += increment;

cout << "Car Max Speed : " << speed << "km/h" << endl;

speed = 20;

dec = decrement;

speed -= decrement;

cout << "Car Min Speed : " << speed << "km/h" << endl;

speed = 20;

}

Car(char *c)

{

color = new char[strlen(c) + 1];

strcpy(color, c);

}

};

Car::~Car()

{

cout << "Get rid of Car Class" << endl;

delete[]color;

}

class SportsCar : public Car{

public:

double zerohund;

SportsCar();

SportsCar(bool able);

~SportsCar();

};

SportsCar::SportsCar(bool able)

{

if (able = true)

cout << "The SportsCar have Sports Mode." << endl;

else

cout << "The SportsCar have not Sports Mode." << endl;

}

SportsCar::~SportsCar()

{

cout << "Get rid of SportsCar Class" << endl;

}


int main()

{

Vehicle *First;

SportsCar *Second,s;

First = new Vehicle(true);

Second = new SportsCar(true);

s.engine = 3000;

s.gear = 7;

s.speed = 20;

s.color = "Gold";

s.zerohund = 3.5;

s.increment=300;

s.decrement=20;

cout << "Car Color : " << s.color << endl;

cout << "Car Engine : " << s.engine << " CC" << endl;

cout << "Car Gear : " << s.gear << " Speed" << endl;

cout << "Car Speed(Minimum) : " << s.speed << " km/h" << endl;

cout << "Zero Hundred : " << s.zerohund << " Seconds" << endl;

delete First;

delete Second;


return 0;


}




그담에 이게 오류메시지



1>last.obj : error LNK2019: "public: __thiscall Car::Car(void)" (??0Car@@QAE@XZ) 외부 기호(참조 위치: "public: __thiscall SportsCar::SportsCar(bool)" (??0SportsCar@@QAE@_N@Z) 함수)에서 확인하지 못했습니다.

1>last.obj : error LNK2019: "public: __thiscall SportsCar::SportsCar(void)" (??0SportsCar@@QAE@XZ) 외부 기호(참조 위치: _main 함수)에서 확인하지 못했습니다.

1>C:\Users\Administrator\Documents\Visual Studio 2013\Projects\last\Debug\last.exe : fatal error LNK1120: 2개의 확인할 수 없는 외부 참조입니다.



레알 궁금하다. 클래스끼리 참조하다가 LNK1120 2019맛보게 되니깐 어떤놈이 문제인지 분간을 못하겠음