注册 登录
编程论坛 VC++/MFC

初学遇问题,求助各大神

zhuceliyang 发布于 2012-10-20 14:51, 461 次点击
水平低,没办法,求助


#include<alloc.h>
#include<string.h>
  class Blank
  {
  public:
      Blanks(){}
      void *operator new(size_t stAllocateBlock,char chInit);
      };
  void *Blanks::operator new(size_t stAllocateBlock,char chInit)
  {
      void *pvTemp=malloc();
      if(pvTemp!=0)
     memset(pvTemp,chInit,stAllocateBlock);
      return pvTemp;
  }
  int main()
  { Blanks*a5=new(0xa5)Blanks;//创建对象Blanks,并且初试化为0xa5
    return!=0;
  }
错误fatal error C1083: Cannot open include file: 'alloc.h': No such file or directory
执行 cl.exe 时出错.
3 回复
#2
cyhdahua2012-10-20 19:44
MS VC++ 编译器, 不需要写它。老式unix,linux要写 #include <alloc.h>
 malloc   是在stdlib.h里面
另外还有一些错误  你自己改吧
#3
zhuceliyang2012-10-22 17:48
回复 2楼 cyhdahua
谢谢,俺去试试的说!
#4
chaxiu2012-10-24 23:47
楼上说的没错。。。
1