#ifndef DDXX_QT_H #define DDXX_QT_H class BA { class SB; public: BA(); ~BA(); int bc; static int bd; void funp(SB* pSb); private: int ba; static int bb; public: class SB { public: SB(); ~SB(); int sa; static int sb; void func(BA* pBa); private: int sc; static int sd; }; }; #endif//QT.cpp
#include "QT.h" #includeusing namespace std; int BA::bd = 12; int BA::bb = 13; int BA::SB::sb = 21; int BA::SB::sd = 23; BA::BA() { ba = 1; bc = 2; } BA::~BA() { } void BA::funp(BA::SB* pSb) { pSb = new BA::SB(); pSb->sa; pSb->sb; //pSb->sc; //private //pSb->sd; //private delete pSb; pSb = NULL; } BA::SB::SB() { } BA::SB::~SB() { } void BA::SB::func(BA* pBa) { cout< ba< bb< bc< bd<
//main.cpp
#include#include "QT.h" using namespace std; void main() { BA T; T.funp(NULL); //BA::SB 當修飾符為private時候,不能被外部訪問 BA::SB Tb; Tb.func(NULL); }