Answer to Question #22966 in C++ for Anna

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:
1
Expert's answer
2013-01-28T09:36:34-0500
#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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS