Sunday, July 12, 2009

C++??!! please I need help in my homework and no time just tomorrow?

here is the question:


You have the following program:


//Combined.cpp





class A {


int i;


public:


A(int ii) : i(ii) {}


~A() {}


void f() const {}


};





class B {


int i;


public:


B(int ii) : i(ii) {}


~B() {}


void f() const {}


};





class C : public B {


A a;


public:


C(int ii) : B(ii), a(ii) {}


~C() {} // Calls ~A() and ~B()


void f() const { // Redefinition


a.f();


B::f();


}


};





int main() {


C c(47);


} ///:~


1. Modify Combined.cpp to add another level of inheritance and a new member object. Add code to show when the constructors and destructors are being called.





2. In Combined.cpp, create a class D that inherits from B and has a member object of class C. Add code to show when the constructors and destructors are being called.

C++??!! please I need help in my homework and no time just tomorrow?
uh-oh.... that just might be your grade on this assignment...
Reply:Perhaps you should post this question under computers. Looks like programming of some sort.


No comments:

Post a Comment