考慮下面的代碼: #include <iostream>
using namespace std;
class B;
class A
{
public:
A() { p = 1;}
int p;
operator B() {B b; b.x = this->p; return b;}
};
class B
{
public:
i
int main()
{
// forward declaration
struct myStruct_st *mS; // Note that this will expand as "struct struct myStruct_st *mS which does not make any sense to me"
return 0;
}
// defi
是否有可能將聲明前向聲明的類的成員函數聲明爲朋友?我試圖做到以下幾點: class BigComplicatedClass;
class Storage {
int data_;
public:
int data() { return data_; }
// OK, but provides too broad access:
friend class
//cannot declare operator<<(...) here:
//forward declarations:
class External;
template<class T, class Y>
class External::Internal;
template<class T, class Y>
std::ostream& operator<<(std::ost