cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Class and SubClass
Class and SubClass
May 6, 2013 at 10:08pm UTC
spikeash20
(5)
Hello, I have a class and I want to have a subclass from that.
a) How do I code that?
b) A class can acess to the private members from the subclass?
May 6, 2013 at 11:36pm UTC
blueberry
(130)
A)
1
2
3
4
5
6
7
8
9
class
fruit { };
class
apple :
public
fruit { };
B) You can't. That would defeat the whole point of having private members. You can however, declare those members as protected, which allows only derived classes (its subclasses) to access them.
Topic archived. No new replies allowed.