-1

Scenario: I Want to use the Parent methods in child. Is it possible to create a solution with two dialog classes as shown below?

//Parent is created using class wizard(inherited from CDialog)  
class CDlgParent : public CDialog


//Child class created using class wizard(inherited from CDialog) and then  
  //changed the inheritance  
class CDlgChild : public CDlgParent
Deduplicator
  • 44,692
  • 7
  • 66
  • 118
RENN
  • 11
  • 1. what i need is the two dialog classes, one is parent and other one inherited from parent. child dialog uses the base methods. any help is appreciated. – RENN Nov 03 '15 at 15:29
  • Yes it is possible. Have you tried it? It is real straightforward procedure. – Andrew Komiagin Nov 03 '15 at 17:03

1 Answers1

0

just to exemplify

class A
{
private:
    void privateMethod(){}
protected:
    void protectedMethod(){}
public:
    void publicMethod(){}
};
class B : public A
{
    void methodB()
    {
        //privateMethod();
        protectedMethod();
        publicMethod();
    }
};

just copy this in your code and you will see that it will compile.
If you uncomment the line, it will not compile anymore, giving an error like:

cannot access private member declared in class 'A'

So the only methods that you cannot use from B, that inherits from A, are the private methods, all the others can just be used normally

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Robson
  • 916
  • 5
  • 22