d**********o 发帖数: 41 | 1 我想把一个class A的new 重载成:
void* operator new(size_t sz, string s){...}
在这个class A里有一个静态的vector,记录string s
也就是说这个vector在每次动态分配空间的时候记录一些信息,比如__FILE__, __LINE
__
但是编译出错说C1001 an internal error has occurred in the compiler, 看了半天不
知道怎么错了
OS: windows XP
DE: VC2008
code 见下 | d**********o 发帖数: 41 | 2 #include
#include
#include
#include
#include
using namespace std;
class A{
static vector log; //log for dynamic mem alloc, static
string name;
public:
A(string s):name(s){}
void* operator new(size_t sz, string s){
log.push_back(s);
void* p=0;
if(!(p=malloc(sz))) throw bad_alloc();
return p;
}
void showLog(unsigned int index){
cout<
}
};
vector | d**********o 发帖数: 41 | 3 如果我把静态的vector成员变成vector,就都正确了
是不是编译开始的时候分配静态成员内存的时候vector的大小不能确定?
下面的程序是正常的
//=============================================
#include
#include
#include
#include
#include
using namespace std;
class A{
static vector log; //log for dynamic mem alloc, static
string name;
public:
A(string s):name(s){}
void* operator new(size_t sz, int s){
log.push_back(s);
void* p=0;
if(!(p=malloc(sz)) | t****t 发帖数: 6806 | 4 try not to use "string s" in prototype
use const string& s
i.e.
void* operator new(size_t sz, const string& s)
but anyway, internal errors are always compiler bug
LINE
天不
【在 d**********o 的大作中提到】 : 我想把一个class A的new 重载成: : void* operator new(size_t sz, string s){...} : 在这个class A里有一个静态的vector,记录string s : 也就是说这个vector在每次动态分配空间的时候记录一些信息,比如__FILE__, __LINE : __ : 但是编译出错说C1001 an internal error has occurred in the compiler, 看了半天不 : 知道怎么错了 : OS: windows XP : DE: VC2008 : code 见下
| d**********o 发帖数: 41 | |
|