hello..i have homework and wish that i can find help here..
i needed on sunday to be solved..
plz help as much as u can.

consider the definition of the following class:

class CC
{
public :
CC ();                          //line 1
CC (int);                      //line 2
CC(int, int);                 //line 3
CC(double, int);          //line 4
                .
                . 
                .

private:
int u;
double v;
};

a) give the line number containing the constructor that is executed in each of the following declarations.

i.  CC one;
ii. CC two(5,6);
iii. CC three(3.5, 8);

b) write the definition of the constructor in Line 1 so that the PRIVATE member variables are initialized to 0.

c) write the definition of the constructor in line 2 so that the PRIVATE member variable u is initialized according to the value of the parameter, and the private v is initialized to 0.

Edited 3 Years Ago by mike_2000_17: Fixed formatting

for Ans [a] :: -

line 1
line 3
line 4

fro ans :: -

CC()
{
u = 0;
v = 0;
}


for Ans [c] :: -

CC(int i)
{
u = i;
v = 0;
}

Edited 7 Years Ago by crazyboy: n/a

thank u soo much.
if u can plz answer this question also.
its a branch for the previous question

d. write the definition of the constructor in line 3 and 4 so that the private member variables are initialized according to the values of the parameters.

You need to try to do that yourself. We are not here to do your homework for you. If you don't know how to do it then just read your text book that you bought when you signed up for that course.

for Ans [a] :: -

line 1
line 3
line 4

fro ans :: -

CC()
{
u = 0;
v = 0;
}


for Ans [c] :: -

CC(int i)
{
u = i;
v = 0;
}

Don't just give out homework answers. Ask the person what he has done so far and if he has a specific question then guide him through it. You are not really helping anyone in the long-term by just giving away the answers.

-D

d. write the definition of the constructor in line 3 and 4 so that the private member variables are initialized according to the values of the parameters.

the last answer missed defention of class->
i will do just the last one(line 4)...and you should do the rest

CC::CC(double x, int y)
{
u=y;
v=x;
}

Edited 7 Years Ago by #www#: n/a

This article has been dead for over six months. Start a new discussion instead.