Answer to Question #234131 in C++ for SOM

Question #234131


Find the output of the following program. Find errors if any and correct it.


class test

{ int x;

 public:

test(int x)

{x=x; }

void display()

{cout<<x;}

};

int main()

{  test T1(5);

   T1.display();

   return 0;

}


[Assume the necessary header files and namespaces included]

 




1
Expert's answer
2021-09-06T23:58:23-0400
#include <iostream>
using namespace std;
class test


{ int x;


 public:


test(int x)


{this->x=x; }


void display()


{cout<<x;}


};


int main()


{  test T1(5);


   T1.display();


   return 0;


} 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS