我有以下代码:
class A {
public:
...
C *func() { ... }
void func2() { ... }
...
};
class B {
public:
...
B(std::ostream &s, A *curr);
...
};
class C {
public:
...
ostream *stream;
...
}
void A::func2() {
...
std::ostream *astream = func()->stream;
B *env = new B(astream, this);
...
}
但是我B *env = new B(astream, this);
在线上收到以下错误:
myfile.cc:680:86: error: no matching function for call to ‘B::B(std::ostream*&, A* const)’
myfile.cc:680:86: note: candidates are:
myfile.h:194:2: note: B::B(std::ostream&, A*)
myfile.h:194:2: note: no known conversion for argument 1 from ‘std::ostream* {aka std::basic_ostream<char>*}’ to ‘std::ostream& {aka std::basic_ostream<char>&}’
我不确定如何解决这个问题,并希望有任何意见。