Access control + overloading + overriding

B

BDob

Standard documents "Access control is not considered in determining
overriding."

To further explain what's puzzling me, I put up an example below:

class Base
{
public:
virtual void Method1(int a);
void Method2(int b);
private:
void Method2(char c);
};

class Derived : public Base
{
void Method1(int a)
};

If I understand it correctly, "Derived::Method1" should continue to be
overriding "Base::Method1" though access specifiers are different among Base
and Derived classes for "Method1."

Furthermore, "Base::Method2" is still overloaded in Base class, though two
of them separated in different access specifiers.

Is the understanding correct?

Many thanks!
 
C

Chris \( Val \)

| Standard documents "Access control is not considered in determining
| overriding."
|
| To further explain what's puzzling me, I put up an example below:
|
| class Base
| {
| public:
| virtual void Method1(int a);
| void Method2(int b);
| private:
| void Method2(char c);
| };
|
| class Derived : public Base
| {
| void Method1(int a)
| };
|
| If I understand it correctly, "Derived::Method1" should continue to be
| overriding "Base::Method1" though access specifiers are different among Base
| and Derived classes for "Method1."

Yes.

| Furthermore, "Base::Method2" is still overloaded in Base class, though two
| of them separated in different access specifiers.
|
| Is the understanding correct?

Yes.

Cheers.
Chris Val
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,150
Messages
2,570,853
Members
47,394
Latest member
Olekdev

Latest Threads

Top