2015-09-18 101 views
-1

这是非常奇怪的,因为这样的代码:执行的std ::法院不运行模式下打印,但确实在调试模式下

#include <iostream> 
#include "DummySubject.h" 
#include "Shop.h" 

int main(int argc, char* argv[]) 
{ 
    std::cout << "1234567" << std::endl; 
    // more code 
    return 0; 
} 

此代码不会在控制台上打印任何东西,当我执行它在运行模式下,但是当我在调试模式下执行它时,cout在屏幕上打印1234567

任何想法可能是什么问题?

我甚至使用std::flush但它没有帮助。

编辑:

没有包括:

#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; 
} 

还不行。

+0

如果在'iostream'之后放下这两个包含的文件,它会起作用吗? –

+0

检查“DummySubject.h”或“Shop.h”是否有奇怪的事情。 – 101010

+0

@TommyA:没有帮助,查看修改后的代码,谢谢。 – ron

回答

-1

下面是答案:从here

两者

这为我工作在64位的Eclipse在Windows 7上安装使用 MinGW的:

您的项目右击。选择“属性”。

选择新的 窗口左侧的“运行/调试设置”属性。

在右侧窗口中,单击您的可执行文件以突出显示(即 - Test.exe),然后单击“编辑”。

在环境选项卡,点击 “新建”

名称:Path值:路径到你的MinGW的bin目录。 (对我来说,这是: C:\ devcore \ MinGW \ bin)

单击所有窗口上的“确定”关闭。

尝试再次运行,它应该将输出打印到屏幕上。

相关问题