What is the output of the following code snippet? class Cheetah { public: void set_speed(double new_speed); private: double speed; }; void Cheetah::set_speed(double new_speed) { } speed = new_speed; } int main() { Cheetah ch1; ch1.set_speed (144); cout << "Cheetah speed: return 0; 11 << ch1.speed; Cheetah speed: Cheetah speed: 144 The code snippet does not compile. Cheetah speed: 0

icon
Related questions
Question
What is the output of the following code snippet?
class Cheetah
{
public:
void set_speed(double new_speed);
private:
double speed;
};
void Cheetah ::set_speed (double new_speed)
{
}
speed =
}
int main()
{
new_speed;
Cheetah ch1;
ch1.set_speed (144);
cout << "Cheetah speed: " << ch1.speed;
return 0;
Cheetah speed:
Cheetah speed: 144
The code snippet does not compile.
Cheetah speed: 0
Transcribed Image Text:What is the output of the following code snippet? class Cheetah { public: void set_speed(double new_speed); private: double speed; }; void Cheetah ::set_speed (double new_speed) { } speed = } int main() { new_speed; Cheetah ch1; ch1.set_speed (144); cout << "Cheetah speed: " << ch1.speed; return 0; Cheetah speed: Cheetah speed: 144 The code snippet does not compile. Cheetah speed: 0
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer