Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ cout不产生输出_C++_Oop_Io - Fatal编程技术网

C++ cout不产生输出

C++ cout不产生输出,c++,oop,io,C++,Oop,Io,所以我在一个对象的方法中,但是cout语句根本不产生任何输出 #include <iostream> #include <stdio.h> Object::Method() { printf("why is the next line not printing? This one prints fine\n"); std::cout << "This line should print second, but doesnt" <<

所以我在一个对象的方法中,但是cout语句根本不产生任何输出

#include <iostream>
#include <stdio.h>

Object::Method()
{
    printf("why is the next line not printing? This one prints fine\n");

    std::cout << "This line should print second, but doesnt" << std::endl;

    printf("but this line prints fine like the first!\n");
}
#包括
#包括
对象::方法()
{
printf(“为什么下一行不打印?这一行打印得很好\n”);

std::cout代码片段在我的系统上运行良好,您的问题可能来自未在此处列出的代码的其他部分。
在方法的开头尝试
fflush(stdout)
,看看它是否有效。

代码片段在我的系统上运行良好,您的问题可能来自代码中未列出的其他部分。
尝试在方法开始时使用
fflush(stdout)
,看看它是否有效。

您应该使用
std::cout
(C++流)或C样式流。混合它们可能会产生未定义的行为


例如,它们可能有单独的“缓冲”通道。

您应该使用
std::cout
(C++流)或C样式流。混合它们可能会产生未定义的行为


例如,它们可能有单独的“缓冲”通道。

此代码没有问题。请尝试使用SSCCE()。可能已将
std::cout
重定向到控制台输出以外的其他输出源。我真的想不出任何其他解释。您正在使用哪个IDE?因为我认为它与此相关…此代码没有问题。请尝试提出SSCCE()。有可能已将
std::cout
重定向到控制台输出以外的其他输出源。我真的想不出任何其他解释。您使用的是哪个IDE?因为我认为这与此相关…只使用printf允许我的所有代码工作。但我认为它们是为协同工作而设计的?因此我将接受现在还不行。只使用printf就可以让我的所有代码正常工作。但我认为它们是为协同工作而设计的?所以我现在就接受它。不幸的是,它没有效果:/不幸的是,它没有效果:/