Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- class Student
- {
- public:
- Student():num(),score(){}
- 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;
- }
- void display()const
- {
- cout << num << " " << score << endl;
- }
- private:
- int num;
- float score;
- };
- int main(int argc, char* argv[])
- {
- const Student st(100, 78.5);
- st.display();
- Student *p = (Student*)(&st);
- p->change(1, 2);
- p->display();
- st.display();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement