Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > IT форум > Помощь студентам
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 30.11.2009, 15:04   #1
luk4196
Пользователь
 
Регистрация: 30.11.2009
Сообщений: 10
Смущение Ошибка компиляции

А у меня другая проблема
компилятор викидивает такую ошибку:
[ILINK32 Error] Error: Unresolved external 'Airplane::~Airplane()
[ILINK32 Error] Error: Unresolved external 'Airplane::Airplane(const char *, int)
[ILINK32 Error] Error: Unresolved external 'Airplane::SendMessageA(int, char *, int, int, int)
вот код 1:
Код:
//-----------------------------AIRPORT.CPP----------------------------------------------
#include <vcl\condefs.h>
#include <vcl.h>
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#pragma hdrstop
USERES("Airport.res");
USEUNIT("airplane.cpp");
#include "planer.h"
#include <tchar.h>
//---------------------------------------------------------------------------
#pragma argsused
int getInput(int max);
 int i = 0;
void getItems(int& speed, int& dir, int& alt);
int _tmain(int argc, _TCHAR* argv[])
{
   char returnMsg[100];
   Airplane* planes[3];
   planes[0] = new Airplane("TWA 1040");
   planes[1] = new Airplane("United Express 749", COMMUTER);
   planes[2] = new Airplane("Cessna 3238T", PRIVATE);
	 do {
		 int plane, message, speed, altitude, direction;
		 speed = altitude = direction = -1;
		  cout << endl << "Who do you want to send a message to?";
		  cout << endl << endl << "0. Quit" << endl;
			for (int i = 0; i < 3; i++){
			  cout << i + 1 << ". " << planes[i] ->name << endl;
			  plane = getInput(4);
			  if (plane == -1) break;
			}
			cout << endl << planes[plane]->name << ", roger.";
			cout << endl << endl;
			cout << "What message do you want to send?" << endl;
			cout << endl << "0. Quit" << endl;
			cout << "1. State Change" << endl;
			cout << "2. Take Off" << endl;
			cout << "3. Land" << endl;
			cout << "4. Report Status" << endl;
			message = getInput(5);
			if (message == -1) break;
			if (message == 0)
			  getItems(speed, direction, altitude);
			  bool goodMsg = planes[plane]->SendMessage(message,
			  returnMsg, speed, direction, altitude);
		if (!goodMsg) cout << endl << "Unable to comply.";
			cout << endl << returnMsg << endl;
			}while (1);
		for (int i = 0; i < 3; i++) delete planes[i];
			}
	 int getInput(int max)
	{
		int choice;
		do {
			choice = getch();
			choice -=49;
		} while (choice < -1 || choice > max);
		return choice;
	}
	void getItems(int& speed, int& dir, int& alt)
	{
		cout << endl << "Enter new speed: ";
		getch();
		cin >> speed;
		cout << "Enter new heading: ";
		cin >> dir;
		cout << "Enter new altitude: ";
		cin >> alt;
		cout << endl;
	 getchar();
	}
//------------------------------------------------------------------
Learn,learn and once again learn

Последний раз редактировалось Stilet; 30.11.2009 в 15:45.
luk4196 вне форума Ответить с цитированием
Старый 30.11.2009, 15:14   #2
luk4196
Пользователь
 
Регистрация: 30.11.2009
Сообщений: 10
По умолчанию Код 2 и 3

код 2
Код:
//----------------------------AIRPLANE.CPP-----------------------------------------------
#include <iostream.h>
#include <stdio.h>
#include "planer.h"
#include <vcl.h>
#pragma hdrstop
#include <tchar.h>
Airplane::Airplane(const char* _name, int _type):
type(_type),
status(ONRAMP),
speed(0),
altitude(0),
heading(0)
{
	switch (type) {
	   case AIRPLANER : ceiling = 35000; break;
	   case COMMUTER  : ceiling = 20000; break;
	   case PRIVATE   : ceiling = 8000;
   }
	name = new char[50];
	strcpy(name, _name);
	}
	Airplane::~Airplane()
	{
		delete[] name;
	}
	bool
	Airplane::SendMessage(int msg,char* response,
	  int spd, int dir, int alt)
	  {
		  if (spd > 500) {
			strcpy(response, "Speed cannot be more than 500.");
			return false;
		  }
		  if (dir > 360) {
			strcpy(response, "Heading cannot be over 360 degrees.");
			return false;
		  }
		   if (alt < 100 && alt != -1) {
			 strcpy(response, "I'd crash, bonehead!");
			 return false;
		   }
		   if (alt > celling) {
			  strcpy(respose, "I can't go that high.");
			  return false;
		   }
		switch (msg) {
		   case MSG_TAKEOFF : {
			   if (status != ONRAMP) {
				  strcpy(response, "I'm on the ground");
				  return false;
		   }
			 TakeOff(dir);
			   break;
		}
		   case MSG_CHANGE : {
			   if (status == ONRAMP) {
				  strcpy(response, "I'm on the ground");
			   return false;
			   }
			   if (spd != -1) speed = spd;
			   if (dir != -1) heading = dir;
			   if (alt != -1) altitude = alt;
				status == CRUISING
				break;
	  }
		  case MSG_LAND : {
			  if (status == ONRAMP) {
				 strcpy(response, "I'm already on the ground.");
				 return false;
			  }
			  Land();
			  break;
		  }
		   case MSG_REPORT : ReportStatus();
		  }
		strcpy(response, "Roger.");
		return true;
		}
		void
		Airplane::TakeOff(int dir)
		{
			heading = dir;
			status = TAKINGOFF;
		}
		void
		Airplane::Land()
		{
			speed = heading = altitude = 0;
			status = ONRAMP;
		}
		int Airplane::GetStatus(char* statusString)
		{
			sprintf(statusString, "%s, Altitude: %d, Heading: %d,"
			"Speed: %d\n", name, altitude, heading, speed);
		}
		void
		Airplane::ReportStatus()
		{
			char buff[100];
			GetStatus(buff);
			cout << endl << buff << endl;
		}
//----------------------------------------------------------------------
код 3
Код:
//--------------------------PLANER.h-----------------------------------------
#ifndef planerH
 #define planerH
 #define AIRPLANER   0
 #define COMMUTER    1
 #define PRIVATE     2
 #define TAKINGOFF   0
 #define CRUISING    1
 #define LANDING     2
 #define ONRAMP      3
 #define MSG_CHANGE  0
 #define MSG_TAKEOFF 1
 #define MSG_LAND    2
 #define MSG_REPORT  3
 class Airplane {
	 public:
	 Airplane(const char* _name, int _type = AIRPLANER);
	 ~Airplane();
	 virtual int GetStatus(char* statusString);
	 int GetStatus()
	 {
		 return status;
	 }
	 int Speed()
	 {
		 return speed;
	 }
	 int Heading()
	 {
		 return heading;
	 }
	 int Altitude()
	 {
		 return altitude;
	 }
	 void ReportStatus();
	 bool SendMessage(int msg, char* response,
	 int spd = -1, int dir = -1, int alt = -1);
	 char* name;
   protected:
	  virtual void TakeOff(int dir);
	  virtual void Land();
   private:
	  int speed;
	  int altitude;
	  int heading;
	  int status;
	  int type;
	  int ceiling;
};
#endif
//-----------------------------------------------------------------
Learn,learn and once again learn

Последний раз редактировалось Stilet; 30.11.2009 в 15:46.
luk4196 вне форума Ответить с цитированием
Старый 30.11.2009, 22:11   #3
lennon
Заблокирован
 
Регистрация: 18.11.2007
Сообщений: 254
По умолчанию

уважаемый ))) добавте файл AIRPLANE.CPP к проекту )
lennon вне форума Ответить с цитированием
Старый 30.11.2009, 22:39   #4
luk4196
Пользователь
 
Регистрация: 30.11.2009
Сообщений: 10
По умолчанию

Ви видемо чевото непоняли AIRPORT.CPP ето главний вайл которий соеденяет AIRPLANE.CPP и PLANER.h он берет данние из них
при компиляции вместе а не отдельно он викидивает ошибку
Learn,learn and once again learn
luk4196 вне форума Ответить с цитированием
Старый 30.11.2009, 23:14   #5
lennon
Заблокирован
 
Регистрация: 18.11.2007
Сообщений: 254
По умолчанию

это вы чегото непоняли. я говорю файл CPP в проект добавте. Компилятор незнает где находиться AIRPORT.CPP
есил в оснойном исходнике написали include "AIRPORT.h", то это ему понятно, на этапе конпоновки, компилтор пытаеться найти реализацию описателей и не находит, потому что вы не добавили в проект AIRPORT.CPP.
B когда вы все же решите добавить его в проект, можете добавить мне отзыв
lennon вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Ошибка компиляции ALEX INCORPORATEED Помощь студентам 7 14.09.2012 00:46
Ошибка при компиляции haste39 Общие вопросы C/C++ 4 13.11.2009 00:24
Ошибка компиляции С++ jeka101 Общие вопросы C/C++ 3 27.03.2009 19:16
Ошибка при компиляции CrazyRabbit Общие вопросы C/C++ 3 25.12.2008 18:41
Ошибка при компиляции MasterofCDM Общие вопросы Delphi 2 11.11.2008 09:35