Home > Back-end >  This problem of stu1 exactly how to do? Bosses save the children
This problem of stu1 exactly how to do? Bosses save the children

Time:04-16

Define the student class student, data members include students student id number and grade score, define three member function (enter student id and grades, modified result, output the student id and grades), define s1 students object input and output student id and record; Define the pointer variable p student id to objects s2 input and output result; Objects defined stu1 s1 references, and use the score on the reference to modify s1 and output,

CodePudding user response:

This means, for reference:
 int main () 
{

Student s1=new Student ();//define students object s1
S1. Setscore ();//input s1 achievement
S1. Outprint ();//print

Student stu1;

Stu1=s1;//stu1 and s1 were an address, point to the same address

Stu1. Setscore ();//by using reference to modify s1 achievement

S1. Outprint ();//print to see the results
Stu1. Outprint ();

}
  • Related