【问题】做C++习题时碰到一个超简单程序却执行慢的问题
【OS】windows7 ultimate(64bit)
【IDE】visual studio 2012
【现象描述】编译成功且无告警,逐过程调试也很流畅。
但在command prompt窗口中执行时卡了30几秒才出现打印消息。
【源码】
//class.h
#include <iostream>
using namespace std;
class C;
class B
{
private:
void msg()
{
cout << "This msg from B class." << endl;
}
public:
void bridge(){msg();}
void caller(C* c);
};
class C
{
private:
void msg()
{
cout << "This msg from C class." << endl;
}
public:
void bridge(){msg();}
void caller(B* b)
{
b->bridge();
}
};
void B::caller(C* c)
{
c->bridge();
}
//源.cpp
#include <iostream>
#include "class.h"
using namespace std;
int main()
{
B b;
C c;
b.caller(&c);
c.caller(&b);
return 0;
}
[解决办法]
是不是编译器出了点问题??