Hi! Please help me debug the following code in C++. Below, you may find the prompt, the code and the identified error.

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Hi! Please help me debug the following code in C++. Below, you may find the prompt, the code and the identified error.

Post by answerhappygod »

Hi! Please help me debug the following code in C++. Below, you may find the prompt, the code and the identified error. Please Identify what is incorrect, correct the code, and provide comments to explain. Thanks!
\/ athlete.h 1 2 3 4 5 6 7 8 9 16 11 12 13 14 15 16 17 #include <iostream> using namespace std; // lots us use c++ throughout entire program class Athletes // creates a class for athletes with their name and height [ private: // access specifier - cannot be accessed/modified from outside the class string name; // private attribute - defines name as a string double height: // private attribute - defines heritht as a integer publici // access specifier can be accessed/modified from outside the class Athletes(string, double ); // public attribute - function void setName(string); // public attribute - set function which returns nothing void setHeight (double); // public attribute - set function which returns nothing string getName(); // public attribute - get function which returns a string double getHeight(); / public attribute - set function which returns a integer 3:

// athlete.cpp #include'athlete.h" // lets us work with Athlete.h Athletes: : Athletes (string n, double h) // defines functions { setName(n); // assign setter value setHeight(h); // assign setter value name = n; // defines names string set function height = h; // defines height integer set function } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 void Athletes::setName(string n) // voids setName function { name = n; 3 void Athletes::setHeight (double h) // voids setHeight function { height = h; } string Athletes::getName() // defines getName function { return name; returns the value of name as a string 1 e double Athletes::getHeight() // defines the getHeight function { return height; returns the value of height as a double 3

7/ client.cpp #include <iostream> //lets us work with cout #include athlete.cpp" // lets us work with using namespace std; // lets us use c++ throughough entire program 1 2. 3 4 5 6 7 8 9 10 11 12 13 14 int main() // main function Athletes ooc("Usain Bolt",77); // creates Athletes object of class cout << "Name: " << ooc.getName() << endl; // prints name with object of class cout << "Height: " << ooc.getHeight() << inches << endl; prints height with object of class return e; // lots computer know everything ran okay w
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply