Using Inheritance one classes

Apr 30, 2011 at 10:40am
Using Inheritance one classes question.

Class hello
{
public:
int hi;
}welcome[2];

what would the inheritance be for this class?does the inheritence copy the values in the welcome array aswell and if that happens, changing any values later on in the code from welcome[0].hi,welcome[1].hi,welcome[2].hi would they change in the other class as well?javascript:PostPreview()
Apr 30, 2011 at 11:00am
There's no inheritance here.
I'd suggest looking at the appropriate chapter again.
Apr 30, 2011 at 11:39am
How do I Make an Inheritance from this class, dont u read?
Apr 30, 2011 at 2:26pm
An example of "Inheritance from this class" (assuming that you correct your class declaration) would be:
1
2
3
4
5
class CDerivedHello : public hello
{
public:
  char *sGreetings;
}
Your "welcome" identifier is for an array of "hello" objects, and declaring another class (using inheritance or not) won't change this "welcome" in any way (it still will be as warm as ever). Having another defined class gives you the possibility to declare and use another kind of objects (with some degree of backward compatibility). But objects are independent. Changing something in the "hello" class objects won't affect neither the (other) objects of the same class, nor the objects of some derived class.
_________________________________
P.S.: You're here on a C/C++ forum so please no javascript here!
Apr 30, 2011 at 5:37pm
This is java? didn't know, i am using a different one from c++ but its linked into c++ very closely. so your saying if i wanted Derivedhello[0].hi and hello[0]. hi to be same number, i have to set each of individually?
Topic archived. No new replies allowed.