PDA

View Full Version : مبتدی: کسی می دونه کد زیر چرا کامپایل نمیشه ؟؟؟



djsohrab2007
یک شنبه 06 شهریور 1390, 02:43 صبح
اولین باره که به یه همچین مشکل می خورم :خجالت: نمی دونم واللا تا الان همینجوری کد می نوشتم و مشکل هم ایجاد نمی شد، اما حالا !!!!!!!

لطف کنید بگید چرا این کد اجرا نمی شه ؟

فایل .h


#pragma once

#ifdef DLL_EXPORT
#define DECLDIR __declspec(dllexport)
#else
#define DECLDIR __declspec(dllimport)
#endif

namespace Dll
{
class Interface
{
public:
virtual void Function1( int ) ;
virtual int Function2 ( void ) ;
virtual void Deletethis();
virtual ~Interface();
};
class Implemention : public Interface
{
public:
virtual void Function1 ( int );
virtual int Function2 ( void ) ;
virtual void Deletethis() ;

};

}
extern "C" DECLDIR Dll::Interface* CreatInstance ();


فایل .cpp

#include"testDLL2.h"
#include<iostream>
using namespace std;
using namespace Dll;

#define DLL_EXPORT

void Implemention::Function1( int a )
{
cout<<a<<endl;
}
int Implemention::Function2( void )
{
return 0 ;
}
void Implemention::Deletethis()
{
delete this;
}
Interface::~Interface()
{
}
extern "C" Dll::Interface* CreatInstance ()
{
return ( new Implemention ) ;
}


اینم از اروری که میده :


74488

djsohrab2007
یک شنبه 06 شهریور 1390, 22:16 عصر
کسی بلد نبود ؟

djsohrab2007
دوشنبه 07 شهریور 1390, 04:39 صبح
وای ، وای اصلا فکرش را هم نمی کردم همچین اشتباهی کرده باشم ، کلاس تعریف کردم و توابع آن را تعریف نکردم درحالی که دارم از آن ارث هم می برم !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
یعنی کافی بود این چند خط را به فایل .cpp اضافه کنم بعد مشکل حل می شد :

void Interface::Function1( int a )
{
}
int Interface::Function2( void )
{
return 0 ;
}

void Interface::Deletethis( void )
{
}