C++的多线程问题, 请大家帮帮忙!!
我写了一个多线程的垃圾回收器程序( 用标准C++ )
然后在project->setting里的C/C++模块中设置了CateGory为Code Generation,
Use run_time library为Multithreaded
一开始用如下代码运行时, 可以正确执行
int main( )
{
try
{
CGCollectorPtr<int, 10> ap = new int[10];//垃圾回收对象
for( int i=0; i<10; i++ )
ap[i] = i;
for( int j=0; j<10; j++ )
cout << ap[j] << endl;
}
catch( bad_alloc exc )
{
return 1;
}
return 0;
}
但用如下代码运行时, 编译器就会自动生成basetsd.h文件, 然后运行有两个错误,
以后换成上面的代码运行时也会有一样的错误
代码:
class MyClass
{
public:
int a, b;
public:
double n[100000];
double val;
MyClass( )
{
a = b = 0;
};
MyClass( int x, int y )
{
a = x;
b = y;
val = 0.0;
};
~MyClass( )
{
cout << "Destructing MyClass{ "<< a << ", " << b << "}" << endl;
}
int Sum( )
{
return a+b;
}
friend ostream& operator <<( ostream& strm, const MyClass &obj );
};
ostream& operator <<( ostream& strm, MyClass& obj )
{
strm<< "(" << obj.a << ", " << obj.b << ")" << endl;
return strm;
}
int main( )
{
CGCollectorPtr<MyClass> mp;
int i;
try
{
for( i=1; i<2000; i++ )
{
mp = new MyClass( i, i );
if( !(i%100) )
{
cout << "list: " << mp.GetSize( )<< " entries" << endl;
}
}
}
catch( bad_alloc exc )
{
return 1;
}
return 0;
}
错误:
Linking...
libcpmtd.lib(xmbtowc.obj) : error LNK2001: unresolved external symbol __CrtDbgReport
Debug/GarbeCollector.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
GarbeCollector.exe - 2 error(s), 0 warning(s)
请大家帮忙解决这个问题
谢谢各位啦..............
问题点数:100、回复次数:7Top
1 楼cenlmmx(学海无涯苦作舟)回复于 2006-03-18 21:59:27 得分 20
没有include <CRTDBG.H>?Top
2 楼ccdd14(LiangLove)回复于 2006-03-18 23:57:32 得分 0
包含也不行呀
一样的错误Top
3 楼jiangsheng(蒋晟.Net[MVP])回复于 2006-03-19 00:54:03 得分 20
信息不足
看http://community.csdn.net/expert/Topicview2.asp?id=4619919怎么问问题的
Top
4 楼MagicCarmack(MagiC++)回复于 2006-03-19 03:06:36 得分 20
收藏。。。Top
5 楼fei8326(天际飞云)回复于 2006-03-19 13:44:45 得分 20
等待答案!Top
6 楼Polarislee(北极星)(无房无车,飘在北京)回复于 2006-03-19 14:06:16 得分 20
你在连接参数中没有加入CrtDbgReport对应的.lib文件Top
7 楼ccdd14(LiangLove)回复于 2006-03-19 16:45:46 得分 0
对应的.lib文件的全名是什么呀
能告诉我吗Top




