У меня есть два файла:< /p>
Код: Выделить всё
// ./include/HelloWorld.hpp
#ifndef __HELLOWORLD_H__
#define __HELLOWORLD_H__
#include
#include
class HelloWorld {
public:
HelloWorld(std::ostream& MyOut);
void say();
private:
std::ostream &output;
};
#endif
Код: Выделить всё
// ./src/HelloWorld.cpp
#include "../include/HelloWorld.hpp"
HelloWorld::HelloWorld(std::ostream &MyOut) : output(MyOut){
output = MyOut; // Error is thrown here
};
void HelloWorld::say(){
this->output
Подробнее здесь: [url]https://stackoverflow.com/questions/78664197/assign-reference-parameter-for-ostream-to-reference-member-variable[/url]