-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;
}
还不行。
如果在'iostream'之后放下这两个包含的文件,它会起作用吗? –
检查“DummySubject.h”或“Shop.h”是否有奇怪的事情。 – 101010
@TommyA:没有帮助,查看修改后的代码,谢谢。 – ron