Hmm. That's odd alright! I'm assuming that code you wrote up there was just for example cause class has a capital c and there isn't a terminating ; after the class definition.
I normally use __declspec(dllimport)/__declspec(dllexport) when I'm using dlls. Something like:
(when making dll):
Code:
#ifndef TWOMERS_APPLE_H
#define TWOMERS_APPLE_H
class __declspec(dllexport) myapple {
private:
int something;
public:
myapple( void );
myapple( int );
int get( void );
void set( int );
};
#endif
Code:
#include "myapple.h" // The above file
myapple::myapple( void ) : something( 24 ) {
}
myapple::myapple( int n ) : something ( n ) {
}
int myapple::get( void ) {
return something;
}
void myapple::set( int n ) {
something = n;
}
Header file linking to it:
Code:
#ifndef TWOMERS_APPLE_H
#define TWOMERS_APPLE_H
#pragma comment( lib, "myapple.lib" )
class __declspec(dllimport) myapple {
private:
int something;
public:
myapple( void );
myapple( int );
int get( void );
void set( int );
};
#endif
And main:
Code:
#include "myapple.h"
int main( void ) {
myapple apple;
std::cout<< apple.get();
apple.set(4);
std::cout<< ", " << apple.get();
return 0;
}
Virtual-ing some functions doesn't affect mine here. To be honest I don't know a whole lot about making dlls and what I showed there mightn't be the best way of doing it but it runs fine for me. What compiler are you using?