本文发表在 rolia.net 枫下论坛//cod.h
#ifndef cod_h
#define cod_h
class cod{
public:
cod();
~cod();
void read_file();
#ifdef _DEC_LIB_
void dec();
#endif
#ifdef _ENC_LIB_
void enc();
#endif
};
#endif
//cod.cpp
#include "stdio.h"
#include "cod.h"
cod::cod()
{
}
cod::~cod()
{
}
void cod::read_file()
{
printf("cod::read_file\n");
}
#ifdef _DEC_LIB_
void cod::dec()
{
printf("cod::dec\n");
}
#endif
#ifdef _ENC_LIB_
void cod::enc()
{
printf("cod::enc\n");
}
#endif
//enc.h
#ifndef enc_h
#define enc_h
class enc{
void *penc;
public:
enc();
~enc();
void encode();
};
#endif
//dec.h
#ifndef dec_h
#define dec_h
class dec{
void *pdec;
public:
dec();
~dec();
void decode();
};
#endif
//codec.cpp
#include "codec.h"
#include "cod.h"
#ifdef _DEC_LIB_
dec::dec()
{
pdec = new cod;
((cod *)pdec)->read_file();
}
dec::~dec()
{
delete pdec;
}
void dec::decode()
{
((cod *)pdec)->dec();
}
#endif
#ifdef _ENC_LIB_
enc::enc()
{
penc = new cod;
((cod *)penc)->read_file();
}
enc::~enc()
{
delete penc;
}
void enc::encode()
{
((cod *)penc)->enc();
}
#endif
//test.cpp
#include "enc.h"
#include "dec.h"
#pragma comment(lib, "enc.lib")
#pragma comment(lib, "dec.lib")
void main(){
enc e;
e.encode();
dec d;
d.decode();
}更多精彩文章及讨论,请光临枫下论坛 rolia.net
#ifndef cod_h
#define cod_h
class cod{
public:
cod();
~cod();
void read_file();
#ifdef _DEC_LIB_
void dec();
#endif
#ifdef _ENC_LIB_
void enc();
#endif
};
#endif
//cod.cpp
#include "stdio.h"
#include "cod.h"
cod::cod()
{
}
cod::~cod()
{
}
void cod::read_file()
{
printf("cod::read_file\n");
}
#ifdef _DEC_LIB_
void cod::dec()
{
printf("cod::dec\n");
}
#endif
#ifdef _ENC_LIB_
void cod::enc()
{
printf("cod::enc\n");
}
#endif
//enc.h
#ifndef enc_h
#define enc_h
class enc{
void *penc;
public:
enc();
~enc();
void encode();
};
#endif
//dec.h
#ifndef dec_h
#define dec_h
class dec{
void *pdec;
public:
dec();
~dec();
void decode();
};
#endif
//codec.cpp
#include "codec.h"
#include "cod.h"
#ifdef _DEC_LIB_
dec::dec()
{
pdec = new cod;
((cod *)pdec)->read_file();
}
dec::~dec()
{
delete pdec;
}
void dec::decode()
{
((cod *)pdec)->dec();
}
#endif
#ifdef _ENC_LIB_
enc::enc()
{
penc = new cod;
((cod *)penc)->read_file();
}
enc::~enc()
{
delete penc;
}
void enc::encode()
{
((cod *)penc)->enc();
}
#endif
//test.cpp
#include "enc.h"
#include "dec.h"
#pragma comment(lib, "enc.lib")
#pragma comment(lib, "dec.lib")
void main(){
enc e;
e.encode();
dec d;
d.decode();
}更多精彩文章及讨论,请光临枫下论坛 rolia.net