Click here to Skip to main content
15,889,116 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: protected access specifier Pin
David Crow19-Jul-16 17:39
David Crow19-Jul-16 17:39 
AnswerRe: protected access specifier Pin
kinderu20-Jul-16 0:05
kinderu20-Jul-16 0:05 
QuestionRe: protected access specifier Pin
David Crow20-Jul-16 2:53
David Crow20-Jul-16 2:53 
QuestionRe: protected access specifier Pin
Richard MacCutchan20-Jul-16 22:01
mveRichard MacCutchan20-Jul-16 22:01 
AnswerRe: protected access specifier Pin
kinderu21-Jul-16 1:31
kinderu21-Jul-16 1:31 
GeneralRe: protected access specifier Pin
Richard MacCutchan21-Jul-16 1:36
mveRichard MacCutchan21-Jul-16 1:36 
QuestionDebug COM DLL from ASP.Net Pin
Member 741142218-Jul-16 2:00
Member 741142218-Jul-16 2:00 
QuestionInheritance classes Pin
kinderu16-Jul-16 20:32
kinderu16-Jul-16 20:32 
I have the following code.
Why does not my x is displayed.
I do not understand, X is returned by the getX() function wich is called from the derived class SecondClass() through an object of type FirstClass().
Initialization of X was done using constructor function FirstClass(int x).
I did not want to use the initialization function like setX ().



C++
#include <iostream>
using namespace std;
 
class FirstClass
{
private:
    int x;
public:
    FirstClass()
    {
        cout << "\n Default constructor FirstClass()." << endl;
    }
    FirstClass(int x)
    {
        cout << "\n Constructor FirstClass()." << endl;
        this->x = x;
        cout << "\n X = " << x << endl;
    }
    int getX()
    {
        return x;
    }
};
 
class SecondClass:protected FirstClass
{
private:
    int y;
public:
    SecondClass(int x):FirstClass(x)
    {
        cout << "\n Constructor SecondClass()." << endl;
    }
    void printX(FirstClass& obj)
    {
        cout << "\n X = " << obj.getX() << endl;
    }
};
 
int main()
{
    FirstClass box1;
    SecondClass box2(100);
    box2.printX(box1);
    return 0;
}

AnswerRe: Inheritance classes Pin
Daniel Pfeffer16-Jul-16 20:45
professionalDaniel Pfeffer16-Jul-16 20:45 
AnswerRe: Inheritance classes Pin
Albin George18-Jul-16 1:14
Albin George18-Jul-16 1:14 
QuestionUnmanaged DLL used by C# WPF app not receiving WM_DEVICECHANGE Pin
Leif Simon Goodwin15-Jul-16 3:07
Leif Simon Goodwin15-Jul-16 3:07 
QuestionRe: Unmanaged DLL used by C# WPF app not receiving WM_DEVICECHANGE Pin
David Crow15-Jul-16 5:59
David Crow15-Jul-16 5:59 
AnswerRe: Unmanaged DLL used by C# WPF app not receiving WM_DEVICECHANGE Pin
Leif Simon Goodwin17-Jul-16 3:11
Leif Simon Goodwin17-Jul-16 3:11 
AnswerSolved Pin
Leif Simon Goodwin17-Jul-16 20:42
Leif Simon Goodwin17-Jul-16 20:42 
QuestionDirectX 9 in code:blocks fails on initD3D Pin
Korowai14-Jul-16 9:10
Korowai14-Jul-16 9:10 
AnswerRe: DirectX 9 in code:blocks fails on initD3D Pin
leon de boer14-Jul-16 18:13
leon de boer14-Jul-16 18:13 
GeneralRe: DirectX 9 in code:blocks fails on initD3D Pin
Korowai15-Jul-16 6:04
Korowai15-Jul-16 6:04 
GeneralRe: DirectX 9 in code:blocks fails on initD3D Pin
Korowai1-Aug-16 16:19
Korowai1-Aug-16 16:19 
Questionbehaviour when adding custom buttons to CMFCToolBar with CMFCToolBar::ReplaceButton? Pin
Maximilien13-Jul-16 10:27
Maximilien13-Jul-16 10:27 
QuestionCalling C Function in Dll Causing Problem Pin
Django_Untaken12-Jul-16 4:52
Django_Untaken12-Jul-16 4:52 
SuggestionRe: Calling C Function in Dll Causing Problem Pin
Richard MacCutchan12-Jul-16 5:19
mveRichard MacCutchan12-Jul-16 5:19 
GeneralRe: Calling C Function in Dll Causing Problem Pin
Django_Untaken12-Jul-16 5:27
Django_Untaken12-Jul-16 5:27 
AnswerRe: Calling C Function in Dll Causing Problem Pin
Albert Holguin12-Jul-16 5:59
professionalAlbert Holguin12-Jul-16 5:59 
GeneralRe: Calling C Function in Dll Causing Problem Pin
Django_Untaken12-Jul-16 7:18
Django_Untaken12-Jul-16 7:18 
GeneralRe: Calling C Function in Dll Causing Problem Pin
Albert Holguin13-Jul-16 6:36
professionalAlbert Holguin13-Jul-16 6:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.