读程序写结果_1

源程序:

#include <iostream>
using namespace std;

class example
{
private:
int a;
public:
example(int b=5)
{
a=b++;
}
void print()
{
a=a+1;
cout<<a<<" ";
}
void print() const
{
cout<<a<<endl;
}
};
void main()
{
example x;
const example y(2);
x.print();
y.print();
}

运行结果:

 

posted @ 2022-03-20 14:49  bobo哥  阅读(86)  评论(0)    收藏  举报