+skyler_sdf Posted June 24, 2012 Report Posted June 24, 2012 Este posibil sa declaram o clasa, si mai tarziu sa o detaliem... Acest lucru este posibil atata timp cat nu construim obiecte(s.a.) de tipul clasei careia ii amanam detalierea.. De ex: #include<iostream> using namespace std; const int IDLE=0; const int INSUE=1; //forward declaration class C2; class C1{ int status; //IDLE if off, INSUE if on screen public: void set_status(int state); friend int idle(C1 a, C2 b); }; class C2 { int status; //IDLE if off, INSUE if on screen public: void set_status(int state); friend int idle(C1 a, C2 b); }; void C1::set_status(int state) { status=state; } void C2::set_status(int state) { status=state; } int idle(C1 a, C2 b) { if(a.status || b.status) return 0; else return 1; } int main() { C1 x; C2 y; x.set_status(IDLE); y.set_status(IDLE); if(idle(x, y)) cout<<"Screen can be used."; else cout<<"in use. "; x.set_status(INSUE); if(idle(x, y)) cout<<"screen can be used. "; else cout<<"in use"; system("PAUSE"); return 0; }
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now