1、实验 4 友元 静态成员 1 指出程序运行的结果,并分析原因。#includeclass Sampleint a,b;static int c;public:Sample()a=b=0;c+;void show()coutclass scoreint mark10;public:static int tals;static int num;void set() int i;for(i=0;imarki;num+;. /计算总分coutclass scoreint mark10;public:static int tals;static int num;void set() int i;for(
2、i=0;imarki;num+;tals=tals+marki; /计算总分coutclass scoreint mark100;public:static int tals;static int num;void set()int i;coutmarki;num+;tals=tals+marki;/计算总分if(marki=0)break;cout“The scores of the class are following: “endl;for(int k=0;ki;k+)cout“学号:“k+1 ;cout“分数:“markk ;coutendl;coutn;int get_num(void)return (num-1);static int re_tals()return tals;int score:tals=0; /静态数据成员的初始化int score:num=0;void main()score t;cout“Please input the scores of the class:“endl;t.set();cout“The number of the scores is: “t.get_num()endl;cout“The total score of the class is: “t.re_tals()endl;