Dear all,
I have a question about inheritance in C++. Suppose there is a base class called "A", with a protected variable "list_" which basically stores a list of objects with type "P", and also there is a method in class A which adds objects to the list.
There are two classes called "A1" and "A2" respectively, which are derived from the base class "A". assume a1 and a2 are instance of A1 and A2, and a1, a2 add "P" objects based on different conditions, so a1 and a2 have their own list of "P" objects with name "list_", is this correct?
And if the above is true, then is it possible to change one field of a specific "P" object from the "list_" in "a1" with some function in class "A2"?
Thanks a lot for any comment.
Best Regards.
welles
0
Newbie Poster
Recommended Answers
Jump to PostDear all,
I have a question about inheritance in C++. Suppose there is a base class called "A", with a protected variable "list_" which basically stores a list of objects with type "P", and also there is a method in class A which adds objects to the list.
There are …
Jump to PostJust declare that function as friend .
All 7 Replies
jencas
ithelp
757
Posting Virtuoso
Banned
welles
0
Newbie Poster
welles
0
Newbie Poster
stilllearning
148
Posting Whiz
welles
0
Newbie Poster
stilllearning
148
Posting Whiz
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.