The Private Member In Derived Class

The Private Member In Derived Class




🛑 👉🏻👉🏻👉🏻 INFORMATION AVAILABLE CLICK HERE👈🏻👈🏻👈🏻




















































Because it accesses i via the method set: such method is protected hence accessible from Derived.
while we didn't allocate memory to i and didn't create an object of class Base
how it can be done?
What do you mean allocate? -- it's not a pointer! Look, I see you completely lost in basics of programming. You need to step back and really understand variables, parameters, pointers, etc. before you go into OOP. This is what stops you, not classes.
--SA
You've just lost 1000 C++ points, with this comment. Please read a good book on C++ and OOP (if you create an object of class Derived, you get, for free, all the members, of class Base, because Derives is Base too. That's one of the reason inheritance is made for).
Correct, a 5. OP is totally lost (see my answer).
--SA
This is not true: "private members doesn't Derive". This is not even false, just makes no sense. :-)
A member can not "derive", only a type can. All members are inherited, no exclusions.


—SA
so,how change method of Derived class works?
Because the protected member function "Set" accesses the private member - which it is allowed to do, being a part of the "Base" class. The derived class cannot access private "Base" members except via Protected or public methods. Even then it has no direct access, it can only provide a parameter value which the protected function then uses as it will.
Your protected code accesses your private member. It works as it should. What you want to do, is not clear, so 'works' is not defined.
Ouch, you just earned yourself a thorough whip-lashing with that suggestion!
;-p
Possibly - I did mention something about the dirty tricks department :)
Treat my content as plain text, not as HTML
I have read and agree to the Terms of Service and Privacy Policy
Please subscribe me to the CodeProject newsletters
When answering a question please:

Read the question carefully.
Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
Copyright © CodeProject, 1999-2021
All Rights Reserved.

Web03 2.8.20210820.1

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900

Sign up or log in to view your list.
Now, class derived has public member:
protected member: int b; private member: int d; I can't comfirm if int c; is a private member of class derived. It's clear that any new member function of class derived can't access c. So, if c is a private member of class derived, the member function of class derived should have right to access c. So c is a what kind of member of class derived?
buweilv
buweilv 351●33 silver badges●1717 bronze badges
c is not a member of derived, it's a member of base, just like a and b. – n. 1.8e9-where's-my-share m. Jul 29 '17 at 6:19
so, a is a public member of derived ? b is a protected member of derived?@n.m. – buweilv Jul 29 '17 at 6:22
A derived class doesn't inherit access to private data members. However, it does inherit a full parent object, which contains any private members which that class declares.
Chandan Purbia
Chandan Purbia 255●33 silver badges●1414 bronze badges
So, this means derived class inherit a full parent object, so is the private member in base class is also a private member of derived class, but this private member is special, because derived class doesn't inherit access to private data members? – buweilv Jul 29 '17 at 6:34
Listen, in simple words, I'll try to explain. If there is a private member in the base class which you want to access through a member of derived class, you make some public or protected member functions (getters and setters) in the base class. Here in your case, you cannot access the variable a of the base class from derived class, to do so, make some getters and setters in the base class in either public or protected. I hope this helps. – Chandan Purbia Jul 29 '17 at 6:42
Thanks for your explaining, I understand how to access private memeber of base class from derived class. My question is simple, Does private member of base class belong to derived class private member? From your answer, I see, yes, private member of base class belongs to derived class private member, it's just a special one which derived class can't directly access it. – buweilv Jul 29 '17 at 6:54
Yes, this is the case. It'd be better if you go through the link I have provided in my answer. – Chandan Purbia Jul 29 '17 at 7:21
I will clarify this with an example.
Now coming to the question each class access modifier has the following arrangement
SRIDHARAN
SRIDHARAN 925●11 gold badge●1313 silver badges●2727 bronze badges
HI, I have the same understanding with you, the point is derived actually never know c's existense, but is c actually existing in class derived, just like this answer. – buweilv Jul 29 '17 at 7:05
of course "c" is still inside derived see this ideone.com/LPR7g2 – SRIDHARAN Jul 29 '17 at 7:30
@buweilv it is there but you dont have direct access to it, though you can access it through getC that derived inherited from base – 463035818_is_not_a_number Jul 29 '17 at 8:02
Click here to upload your image (max 2 MiB)
You can also provide a link from the web.
By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy
2021 Stack Exchange, Inc. user contributions under cc by-sa
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Accept all cookies Customize settings

Pictures Of Naked Women In Hammocks
Classic Nylon Dvd Video
Fanny Porno Caldo Mature Da Goarabporn Com
Torrent Perversefamily Com Squirt For Daddy
3gpporn Mobi Mature Extreme Orgasm
[Solved] access private members in derived class - CodeProject
Base class private member belongs to which part of Derived ...
The private member in derived | CareerCup
C++ Tutorial: Private Inheritance - 2020
Accessing protected members in a C++ derived class
Can derived class access private members of base class ...
inheritance - Are private members inherited in C#? - Stack ...
Derived classes - cppreference.com
Public, Protected and Private Inheritance in C++ Programming
The Private Member In Derived Class


Report Page