C++ 执行std::cout不';t在运行模式下打印,但在调试模式下打印
考虑到以下代码,这非常奇怪:C++ 执行std::cout不';t在运行模式下打印,但在调试模式下打印,c++,eclipse,c++11,mingw,C++,Eclipse,C++11,Mingw,考虑到以下代码,这非常奇怪: #include <iostream> #include "DummySubject.h" #include "Shop.h" int main(int argc, char* argv[]) { std::cout << "1234567" << std::endl; // more code return 0; } 还是不行。答案如下: 取自 这对我在Windows7上使用64位安装Eclipse
#include <iostream>
#include "DummySubject.h"
#include "Shop.h"
int main(int argc, char* argv[])
{
std::cout << "1234567" << std::endl;
// more code
return 0;
}
还是不行。答案如下:
取自
这对我在Windows7上使用64位安装Eclipse起到了作用
MinGW:
右键单击您的项目。选择“属性”
选择新窗口左侧的“运行/调试设置”属性
窗户
在右侧窗口中,单击可执行文件以突出显示(即-
Test.exe)并单击“编辑”
在环境选项卡中,点击“新建”
名称:路径值:您的MinGW-bin目录的路径。(对我来说,这是:
C:\devcore\MinGW\bin)
单击所有窗口上的“确定”关闭
再次尝试运行,它会将输出打印到屏幕上
如果在iostream
iostream
之后删除这两个include,那么它能工作吗?检查“DummySubject.h”或“Shop.h”是否做了一些奇怪的事情。@TommyA:没有帮助,检查修改后的代码,谢谢。@101010:没有帮助,请参阅编辑,谢谢。@ron可能有关联。
#include <iostream>
//#include "DummySubject.h"
//#include "Shop.h"
int main(int argc, char* argv[])
{
std::cout << "1234567" << std::endl;
// DummySubject mySubject;
//
// // We have four shops wanting to keep updated price set by mySubject owner
// Shop shop1("Shop 1");
// Shop shop2("Shop 2");
//
// mySubject.Attach(&shop1);
// mySubject.Attach(&shop2);
//
// //Now lets try changing the products price, this should update the shops automatically
// mySubject.ChangePrice(23.0f);
//
// //Now shop2 is not interested in new prices so they unsubscribe
// mySubject.Detach(&shop2);
//
// //Now lets try changing the products price again
// mySubject.ChangePrice(26.0f);
return 0;
}