Question #22966

Use integer (or floating-point) to represent the private data of the class. Provide a constructor function that enables an object of this class to be initialized when it is declared. The constructor should contain default values in case no initial values are provided. Provide public member functions for each of the following:

Expert's answer

#include <conio.h>
#include <iostream>

using namespace std;

class Foo
{
private:
int data;

public:
Foo(int data = 0)
{
this->data = data;
}
};

void main()
{
Foo bar();
Foo bar_2(8);
getch();
}

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!

LATEST TUTORIALS
APPROVED BY CLIENTS