Вопрос по c++ – Можно ли передать функции cout или fout в функцию?

20

Error: User Rate Limit Exceeded

#include <iostream>
#include <iomanip>
#include <fstream>

using namespace std;
void helloWorld(char);
ofstream fout;

int main()
{
    fout.open("coutfout.dat");
    helloWorld(c);
    helloWorld(f);

    return 0;
}
void helloWorld(char x)
{
    xout << "Hello World";
    return;
}

Ваш Ответ

2   ответа
38

ostream

void sayHello(ostream& stream)
{
    stream << "Hello World";
    return;
}

Error: User Rate Limit Exceeded ChiefTwoPencils
Error: User Rate Limit Exceeded
Error: User Rate Limit ExceededstreamError: User Rate Limit Exceededstd::ostream& sayHello(std::ostream& stream){return stream << "Hello World";}
Error: User Rate Limit Exceededen.cppreference.com/w/cpp/io/basic_ostreamError: User Rate Limit Exceeded
12

Error: User Rate Limit Exceeded

sayhello(std::ostream &os);

Error: User Rate Limit ExceededosError: User Rate Limit Exceededxout.

Error: User Rate Limit Exceededusing namespace stdError: User Rate Limit Exceededusing std::coutError: User Rate Limit Exceeded

Error: User Rate Limit Exceededusing std::coutError: User Rate Limit ExceededcoutError: User Rate Limit Exceeded ChiefTwoPencils
Error: User Rate Limit Exceededusing std::coutError: User Rate Limit ExceededcoutError: User Rate Limit ExceededcoutError: User Rate Limit Exceeded

Похожие вопросы