Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this code the ostream operator is not working properly and the text is not getting printed. Kindly correct this code. class Tyre{ private: int*

In this code the ostream operator is not working properly and the text is not getting printed. Kindly correct this code.

class Tyre{

private:

int* width;

int* aspect_ratio;

int* diameter;

public:

Tyre(int wid, int asp, int diam) {

width = &wid; aspect_ratio = &asp; diameter = ⋄

}

//Constructors, Getters and Destructor

friend ostream& operator << (ostream& out, Tyre t1) {

out << "Tyre Width is : " << t1.width << endl;

out << "Tyre Aspect ratio is : " << *t1.aspect_ratio << endl;

out << "Tyre Diameter is : " << *t1.diameter << endl;

return out;

}

~Tyre() {

delete [] width;

width = nullptr;

delete[] aspect_ratio;

aspect_ratio = nullptr;

delete[] diameter;

diameter = nullptr;

}

};

int main() {

Tyre tNew(12, 10, 13);

cout << tNew;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

Write a note on Historical Development of clinical Trials?

Answered: 1 week ago