关于dllimport的问题
问:在使用VC6时,从一个DLL程序中调用函数时遇上了如下几个问题。 *我将所
有的DLL文件全部拷入debug目录中,也将相应的设置改变了. * 但编译器依然不承
认下面这条语句:
__declspec (dllimport) HIMG SCTAPI ImgLoad(char SCTPTR pcName);
2 errors:
C2146: Syntax error: missing ; before SCTAPI
C1004: unexpected end of file found
* 如果我这样声明
extern "C" __declspec (dllimport) HIMG SCTAPI ImgLoad(char SCTPTR pcName);
就会有三个错误,包括上面2个以及:
C2501 HIMG: missing storage class or type specification.
*另外,我也试过改变Debug的设置加入4个DLL文件,没有用.
答:看上去HIMG声明没有被编译器所识别,你有没有加入相应的头文件?
Cobject的多重继承问:为什么不能多重继承Cobject类:我的继承关系如下:
Cobject
/
Cobject Cfluid
\ /
CPSD Cslurry
\ /
Csuspension
答:使用虚继承类可以解决你的问题
#include
#include
#pragma hdrstop
class CPSD : virtual public Cobject
{};
class Cfluid : virtual public Cobject
{};
class Cslurry : public Cfluid
{};
class Csuspension : public CPSD, public Cslurry
{};
extern "C" void _tmain ()
{ Csuspension mySuspension;
}