首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

类外定义函数过程异常,需要注意哪些呢

2013-08-13 
类外定义函数过程错误,需要注意哪些呢事情是这样的,我写了一个类在类内定义过程的话 没有问题,但是把类的

类外定义函数过程错误,需要注意哪些呢
事情是这样的,我写了一个类在类内定义过程的话 没有问题,但是把类的过程实现放到另外一个文件去实现(同一目录)。
编译测试提示无法解析外部命令。
在类外定义过程需要注意哪些?
比如顺序 或者什么之类的? VS2010
请指教一下。贴上代码

#include "wil.h"
Wil::Wil(char* filename)
{    
     MirRes();
     DataFileName=filename;
     IndexFileName= new char[strlen(DataFileName)+1];
     strcpy(IndexName,DataFileName);
     IndexFileName[strlen(IndexFileName)-1]='x';
  }


void Wil::LoadIndex()
{
   if(bNewFormat) 
   ResFile.read((char*)&wixheader,sizeof(wixheader)-4) else ResFile.read((char*)&wixheader,sizeof(wixheader));
   IndexList=New DWORD[ResCount];
   ResFile.read((char*)IndexList,ResCount*sizeof(DWORD));
}

void Wil::LoadPalette()
{
  if(bNewFormat) ResFile.seek(Sizeof(TWilHeader)-4,0) else ResFile.seek(Sizeof(TWilHeader),0);
  MainPalette=new char[1024];
  ResFile.read(MainPalette,1024);
}

int Wil::Image(char* pic,int,short& x,short&y)
{
return 0;
}

int Wil::Init()
{  
   
   ResFile.open(DataFileName,ios::binary);
   if(!ResFile) return DATA_ERROR;
   ResFile.read((char*)&wilheader,sizeof(wilheader));
   if(IndexOffset==0) bNewFormat=true;
   switch(wilheader.ColorCount)
       {
         case 256:{ColorBits=8;LoadPalette();};break;
         case 65536:ColorBits=16;break;
         case 16777216: ColorBits = 24;break;
         default :ColorBits=32;break;
        }
    ResCount=wilheader.ImageCount;
ResFile.close;

ResFile.open(IndexFileName,ios::binary);
    if(!ResFile) return INDEX_ERROR;
    LoadIndex();
ResFile.close;
ResFile.open(DataFileName,ios::binary)
    return 88;
}



#include "mirres.h"
struct WilHeader
{
chartitle[40];
intImageCount;
intColorCount;
intPaletteSize;
intIndexOffset;    //newformat is 16bit pic  not need palette,so this is needless for newformat


};
struct WixHeader
{
chartitle[40];
intIndexCount;
int verflag;       //newformat is read index form 44,oldformat form 48;
};  
struct WilImageInfo
{
shortwidth;
shortheight;
shortx;
shorty;
intlen; // newformat is needless;
};
//-----------------------------------------------------
class Wil:public MirRes
{
public:
  Wil(char* filename);
  virtual ~Wil();
  virtual    void        LoadIndex();
  virtual    void        LoadPalette();
  virtual int Image(char* pic,int,short& x,short&y);
  virtual int Init();  
private:
  boolbNewFormat; // it's means the colorbit is >=16bit ,dont use palette;
  WilHeader wilheader;
  WixHeader wixheader;

};

类 类成员 类外定义过程 C++
[解决办法]
你的析构函数定义了,但是没有写函数体
所以编译器无法解析

热点排行