private variables, functions help
Hey all i am having some problems with an assignment of mine. This is the code it reffences to:
Code:
class xClass
{
public:
void func();
void print() const;
xClass ();
xClass (int, double);
private:
int u;
double w;
{;
The questions are:
Quote:
1) Write the definition of the member function func so that u is set to 10 and w is set to 15.3.
2) Write the definition of the member function print that prints the contents of u and w.
3) Write the definition of the default constructor of the class xClass so the private member variables are initialized to 0.
So far this is what i have for the answers-but im not quite sure i am correct.
Code:
1)
void xClass::func()
{
xClass exmpD;
exmpD.u = 10;
exmpD.w = 15.3;
}
2)
void xClass::print() const
{
cout << u << " " << w << end1;
}
3)
public:
set2Zero()
{
u = 0;
w = 0;
}
So, how do my answers look? Am i wayyyy off? :)
David