C++ inheritance

C, C++, Visual C++, C++.Net Topics
Post Reply
Jane
Corporal
Corporal
Posts: 10
Joined: Sun Jul 19, 2009 9:19 pm

C++ inheritance

Post by Jane » Sun Jul 19, 2009 9:29 pm

hi,

I have question regarding inheritance in C++.

I have two classes as below.

Code: Select all

class A {

public:
    int a;

protected:

private:
    int b;    
}

class B : public A {

public:
    int a;
}
I need to access 'a' of class A. It seems I have to go back to my concepts ;o)
Could someone pls help?

Jane
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: C++ inheritance

Post by Neo » Tue Jul 21, 2009 3:28 pm

You can access varaible 'a' of derived class A as A::a
Post Reply

Return to “C/C++ Programming”