C
cppforlife
I have a question about using 'has a' inheritance. I want to know how
to extend class that had been used in another class. What i mean is if
i have AddressBook class and its private member AddressRecord class how
i can extend AdressRecord class without changing member of AdressBook
class AddressRecord;
class AddressBook{
public:
//...
private:
//...
AddressRecord* add;
};
class AddressRecord{
//..
};
if i will inherit from AddressRecord class i should change private
member od AddressBook class but it violates OCP(open closed principle).
How can i do that dynamiclly using OOP and if i use templates is it
good?
template<class T>
class AddressBook{
public:
//...
private:
//...
T* add;
};
Thank you.
//[email protected]
//www.cppforlife.tk
to extend class that had been used in another class. What i mean is if
i have AddressBook class and its private member AddressRecord class how
i can extend AdressRecord class without changing member of AdressBook
class AddressRecord;
class AddressBook{
public:
//...
private:
//...
AddressRecord* add;
};
class AddressRecord{
//..
};
if i will inherit from AddressRecord class i should change private
member od AddressBook class but it violates OCP(open closed principle).
How can i do that dynamiclly using OOP and if i use templates is it
good?
template<class T>
class AddressBook{
public:
//...
private:
//...
T* add;
};
Thank you.
//[email protected]
//www.cppforlife.tk