C++课件第1B.pptVIP

  • 6
  • 0
  • 约 34页
  • 2016-12-31 发布于贵州
  • 举报
[例1.3] 求两数中最大者 #include iostream using namespace std; int main( ) { int max(int x,int y); //对max函数作声明 int a,b,c; cinab; c=max(a,b); cout“ max = ”cendl; return 0; } int max(int x,int y) //定义max函数 { int z; if(xy) z=x; else z=y; return z;//将z的值返回,通过max带回调用处 } [例1.4] 包含类的C++程序 #include iostream using namespace std; class Student //声明一个类,类名为Student {private: //以下为类中的私有部分 int num; //私有变量num int score; //私有变量score public: void setdata() //定义公有函数setdata { cinnum;

文档评论(0)

1亿VIP精品文档

相关文档