Answer to Question #196442 in C++ for Navya kala

Question #196442

Create a class named TestClass that holds a single private integer field and a public constructor. The only statement in the constructor is one that displays the message “Constructing”. Write a main()function that instantiates one object of the TestClass. Save the file as TestClass.cpp in the folder. Run the program and observe the results


1
Expert's answer
2021-05-21T00:02:08-0400
#include<iostream>
using namespace std;

class TestClass{
  private:
    int x;
  public:
    TestClass(){
      cout<<"Constructing";
    }
};

int main(){
  TestClass p; //p is the object of class
}


Output of following program is after run and save by name TestClass.cpp:

Constructing


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