3.7
来源:互联网 发布:昆明程序员工资 编辑:程序博客网 时间:2024/05/21 15:04
7.(1) #include <iostream>
using namespace std;
class Student
{
public:
Student(int n,float s):num(n),score(s){}
void change(int n,float s)
{
num=n;
score=s;
}
//void display()
void display()const
{
cout<<num<<" "<<score<<endl;
}
private:
int num;
float score;
};
int main()
{
//Student stud(101,78.5);
const Student stud(101,78.5);
stud.display();
//stud.change(101,80.5);
//stud.display();
return 0;
}
(2) #include <iostream>
using namespace std;
class Student
{
public:
Student(int n,float s):num(n),score(s){}
//void change(int n,float s)
void change(int n,float s)const
{
num=n;
score=s;
}
//void display()
void display()const
{
cout<<num<<" "<<score<<endl;
}
private:
//int num;
mutable int num;
//float score;
mutable float score;
};
int main()
{
//Student stud(101,78.5);
const Student stud(101,78.5);
stud.display();
stud.change(101,80.5);
stud.display();
return 0;
}
(3) #include <iostream>
using namespace std;
class Student
{
public:
Student(int n,float s):num(n),score(s){}
void change(int n,float s)
{
num=n;
score=s;
}
void display()
{
cout<<num<<" "<<score<<endl;
}
private:
int num;
float score;
};
int main()
{
Student stud(101,78.5);
Student *p=&stud;
p->display();
p->change(101,80.5);
p->display();
return 0;
}
(4) #include <iostream>
using namespace std;
class Student
{
public:
Student(int n,float s):num(n),score(s){}
//void change(int n,float s)
void change(int n,float s)const
{
num=n;
score=s;
}
//void display()
void display()const
{
cout<<num<<" "<<score<<endl;
}
private:
//int num;
mutable int num;
//float score;
mutable float score;
};
int main()
{
//Student stud(101,78.5);
const Student stud(101,78.5);
stud.display();
const Student *p = &stud;
//stud.change(101,80.5);
p->change(101,80.5);
//stud.display();
p->display();
return 0;
}
(5)#include <iostream>
using namespace std;
class Student
{
public:
Student(int n,float s):num(n),score(s){}
//void change(int n,float s)
void change(int n,float s)const
{
num=n;
score=s;
}
//void display()
void display()const
{
cout<<num<<" "<<score<<endl;
}
private:
//int num;
mutable int num;
//float score;
mutable float score;
};
int main()
{
//Student stud(101,78.5);
const Student stud(101,78.5);
stud.display();
const Student *p = &stud;
//stud.change(101,80.5);
p->change(101,80.5);
//stud.display();
p->display();
return 0;
}
(5)#include <iostream>
using namespace std;
class Student
{
public:
Student(int n,float s):num(n),score(s){}
//void change(int n,float s)
void change(int n,float s)const
{
num=n;
score=s;
}
//void display()
void display() const
{
cout<<num<<" "<<score<<endl;
}
private:
//int num;
mutable int num;
//float score;
mutable float score;
};
int main()
{
//Student stud(101,78.5);
const Student stud(101,78.5);
stud.display();
//const Student *p = &stud;
Student * const p=&stud;
//stud.change(101,80.5);
//p->change(101,80.5);
//stud.display();
p->display();
return 0;
}
- 3.7
- 3.7
- 3.7
- 3.7
- 3.7
- 3.7
- 3.7
- 3.7
- 3.7
- 【3.7】
- ActiveSync 3.7
- hdu1.3.7
- 3.7 数据类型
- 3.7 java
- 实例3.7
- CareerCup 3.7
- 习题3.7
- 3.7WildcardMatching
- 【内部排序】五:快速排序(Quick Sort)详解与代码
- Android内存泄露优化总结
- 【Android开发】图形图像处理技术-常用绘图类之Canvas类
- UIImageView属性
- WEB服务器与应用服务器的区别
- 3.7
- 安卓--页面跳转,不同窗体传递数据
- 线程练习(两个线程交替运行)
- 3.8
- POJ 3159Candies 栈模拟SPFA
- 黑马程序员-java接口
- 一步一步学习androidNDK编程(log调试和解决中文乱码)
- UILabel属性
- 3.9