C++一道关于结构的题目

2025-03-17 06:57:49
推荐回答(1个)
回答1:

With a class "Student" declared as below:
 class Student {
public:
  int id;
  char name[50]; // Data field
  int age; // Data field
  Student();
  Student(int, char*, int);
};
 
You are required to implement the class functions and also two other functions used to process Student objects, which can get output as specified later.
 
void set(Student &, int, char*, int);
void print(Student);
 
1) You don't need to submit the main function.
2) You don't need to include the header file for class declaration by yourself.

With a main function as below:
 int main(){
  Student std1, std2(123, "John Smith", 18), std3(124);
  set(std1, 100, "Bill Gates", 61);
  print(std1);
  print(std2);
  print(std3);
  return 0;
}