#include <iostream>
#include <string>
using namespace std;
class Nwpu;
class Student {
private:
string name;
friend class Nwpu;
public :
Student();
void display();
};
Student::Student() {
name = "RJ010502_李强";
}
void Student::display() {
cout << name;
}
class Nwpu {
public:
void diplay();
class Software {
private:
string banji;
public:
Software();
void display();
};
};
void Nwpu::diplay() {
cout << "西北工业大学";
}
Nwpu::Software::Software() {
banji = "软件学院";
}
void Nwpu::Software::display() {
cout << this->banji << Student::name << endl;
}
void main() {
Nwpu xbgy;
Nwpu::Software rjxy;
Student stu;
xbgy.diplay();
rjxy.display();
stu.display();
}
就是这个方法有问题Student::name老是报错
是我有元声明有问题?还是别的
其实我就是想用嵌套类调用外部类的私有变量
void Nwpu::Software::display() {
cout << this->banji << Student::name << endl;
}
谢谢