正在加载图片...
●●● ●●●●● 构造函数的引入 ●●●● ●●● ● class a i float x,y, 如何实现对象成员数 public 据的快速初始化? float m n: void setxy( float a, float b xa; y=; j void print(void){cout<x<t≤<y<≤endl;} void main(void 对a1对象的公有 A al 成员数据赋初值 alm=10;al,n=20: al.Setxy(2.0, 5.0) 对a对象的私有 al. Print(; 成员数据赋初值class A { float x,y; public: float m,n; void Setxy( float a, float b ){ x=a; y=b; } void Print(void) { cout<<x<<‘\t’<<y<<endl; } }; 构造函数的引入 void main(void) { A a1; a1.m=10; a1.n=20; a1.Setxy(2.0 , 5.0); a1.Print(); } 如何实现对象成员数 据的快速初始化? 对a1对象的公有 成员数据赋初值 对a1对象的私有 成员数据赋初值 4
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有