填空题
以下程序的执行结果是 【15】 。
#include<iostream. h>
class Sample
{
public:
int x:
int y;
void disp()
{
cout<<"x="<<x<<",y="<<y<<end1;
}
};
void main()
{
int Sample:: ** pc;
Sample s;
pc=& Sample: :x;
s.*pc=10;
pc:=&Sample: :y;
s.*pc=20;
s.disp();
}
【参考答案】
x=10,y=20
热门
试题
填空题
下列程序的执行结果为 【13】 。#include <iostream. h>class Point{public:Point(double i, double j) { x=i; y=j;}double Area() const { return 0.0;}private:double x, y;};class Rectangle: public Point{public:Rectangle(double i, double j, double k, double 1)double Area() const {return w * h;}private:double w, h;};Rectangle: :Rectangle(double i, double j, double k. double 1): Point(i,j).{w=k, h=1}void fun(Point &s){cout<<s. Area()<<end1;}void main( ){Rectangle rec(3.0, 5.2, 15.0. 25.0);fun(rec)}