⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example5.cpp

📁 Advanced Internet Programming Lecture 2 C/C++ Review Li,Suke School of Software and Microelectroni
💻 CPP
字号:
#include <iostream>using namespace std;const int IDLE = 0;const int INUSE = 1;class C2;  // forward declarationclass C1 {  int status;  // IDLE if off, INUSE if on screen  // ...public:  void set_status(int state);  int idle(C2 b);  // now a member of C1};class C2 {  int status;  // IDLE if off, INUSE if on screen  // ...public:  void set_status(int state);  friend int C1::idle(C2 b);};void C1::set_status(int state){  status = state;}void C2::set_status(int state){  status = state;}// idle() is member of C1, but friend of C2int C1::idle(C2 b){  if(status || b.status) return 0;  else return 1;}int main(){  C1 x;  C2 y;  x.set_status(IDLE);  y.set_status(IDLE);  if(x.idle(y)) cout << "Screen can be used.\n";  else cout << "In use.\n";  x.set_status(INUSE);  if(x.idle(y)) cout << "Screen can be used.\n";  else cout << "In use.\n";  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -