Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Define a student class with C++, including private data members: id (integer), name (string) and age (integer). Design public type function members,
Define a student class with C++, including private data members: id (integer), name (string) and age (integer). Design public type function members,
ClassAnimal{private:// Change this place to public, and age and weight will become intage's public membership weight}; ClassDog:publicAnimal{// Change public to private, change it to private inheritance, change it to protected, change it to protected inheritance private:int color;; public:void setage(intn); voids etweight(intm); }; void dog::SetAge(intn){ age = n; } void dog::set weight(intn){ weight = m; } int main(){ Dogg = newDog(); g . SetAge(5); g . set weight(6); Return0} You can change the access rights and inheritance mode of ageweight yourself, which is in the comments. Compile it yourself and see the results!