Click here to Skip to main content
15,884,176 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: Convert From c# - For Report Viewer Report save as PDF format Pin
Richard MacCutchan16-Jun-15 21:54
mveRichard MacCutchan16-Jun-15 21:54 
AnswerRe: Convert From c# - For Report Viewer Report save as PDF format Pin
John Schroedl17-Jun-15 8:39
professionalJohn Schroedl17-Jun-15 8:39 
GeneralRe: Convert From c# - For Report Viewer Report save as PDF format Pin
Paramu197317-Jun-15 15:07
Paramu197317-Jun-15 15:07 
QuestionOOP - Error | Unhandled exception at 0x0FD2CCC8 (msvcp110d.dll) Pin
Member 1164129910-Jun-15 2:23
Member 1164129910-Jun-15 2:23 
QuestionRe: OOP - Error | Unhandled exception at 0x0FD2CCC8 (msvcp110d.dll) Pin
Richard MacCutchan10-Jun-15 21:32
mveRichard MacCutchan10-Jun-15 21:32 
QuestionEnabling ListControl pane in MFC (C++) Pin
Yateesh KR12-May-15 22:14
Yateesh KR12-May-15 22:14 
QuestionRe: Enabling ListControl pane in MFC (C++) Pin
Richard MacCutchan13-May-15 2:55
mveRichard MacCutchan13-May-15 2:55 
QuestionInheritance tricky question Pin
Amrit Agr12-May-15 9:30
Amrit Agr12-May-15 9:30 
Hi Friends,

I came through a interesting question in inheritance. Here is the chunk of code and out put is given below.

// Inheritance tricky.cpp : Defines the entry point for the console application.
//

class Foo
{
private:
int i;
public:
Foo()
{
i = 0;
}
void geti()
{
cout << i << endl;
}
};

class Bar : public Foo
{
private:
int j;
public:
Bar()
{
j = 1;
}
void getj()
{
cout << j << endl;
}
};

void display(Foo* obj, int ctr)
{
for (int i = 0; i < ctr; i++)
{
((Foo*)obj + i)->geti();
}
}

int _tmain(int argc, _TCHAR* argv[])
{
Foo myFoo[3];
display(myFoo, 3);
Bar myBar[3];
display(myBar, 3);
return 0;

}

and Output is

0
0
0
0
1
0

The first 3 line is 0 that's fine. But how the 2nd last is 1 ???

Is there is any way that I can get all 0 in output if I am still executing this code

Bar myBar[3];
display(myBar, 3);

PLease help me out.

Thanks in Advance.
Regards,
Amrit

-- modified 12-May-15 15:52pm.
AnswerRe: Inheritance tricky question Pin
Sascha Lefèvre12-May-15 11:38
professionalSascha Lefèvre12-May-15 11:38 
GeneralRe: Inheritance tricky question Pin
Amrit Agr13-May-15 7:47
Amrit Agr13-May-15 7:47 
AnswerRe: Inheritance tricky question Pin
Sascha Lefèvre13-May-15 9:12
professionalSascha Lefèvre13-May-15 9:12 
Questionenglish language implementation Pin
Member 936602117-Apr-15 3:58
professionalMember 936602117-Apr-15 3:58 
AnswerRe: english language implementation Pin
Member 936602117-Apr-15 4:00
professionalMember 936602117-Apr-15 4:00 
Questionmultiple Pin
memoarfaa16-Apr-15 1:28
memoarfaa16-Apr-15 1:28 
GeneralRe: multiple Pin
Richard MacCutchan16-Apr-15 2:20
mveRichard MacCutchan16-Apr-15 2:20 
QuestionHow to swap address of pointers of 2 variables without using a temporary variable? Pin
Amrit Agr13-Apr-15 20:36
Amrit Agr13-Apr-15 20:36 
AnswerRe: How to swap address of pointers of 2 variables without using a temporary variable? Pin
jschell14-Apr-15 13:17
jschell14-Apr-15 13:17 
AnswerRe: How to swap address of pointers of 2 variables without using a temporary variable? Pin
zhijzan7-Jun-15 20:40
zhijzan7-Jun-15 20:40 
AnswerRe: How to swap address of pointers of 2 variables without using a temporary variable? Pin
Shao Voon Wong28-Jun-15 22:13
mvaShao Voon Wong28-Jun-15 22:13 
Questionhow to migrate CORBA to Web Service in C++ Pin
VC_RYK13-Apr-15 20:20
VC_RYK13-Apr-15 20:20 
Questionconsumer.C: In function âint main(int, char**)â: consumer.C:69: error: invalid conversion from âvoid (*)(buffer_t*, char)â to âvoid* (*)(void*)â consumer.C:69: error: initializing argument 3 of âint pthread_create(pthread_t*, const pthread_attr_t*, Pin
Member 1160464113-Apr-15 15:29
Member 1160464113-Apr-15 15:29 
AnswerRe: consumer.C: In function âint main(int, char**)â: consumer.C:69: error: invalid conversion from âvoid (*)(buffer_t*, char)â to âvoid* (*)(void*)â consumer.C:69: error: initializing argument 3 of âint pthread_create(pthread_t*, const pthread_attr Pin
Richard MacCutchan13-Apr-15 21:33
mveRichard MacCutchan13-Apr-15 21:33 
Questionint **p = (int**)new int(5); Confusing !!! Pin
Amrit Agr5-Apr-15 8:32
Amrit Agr5-Apr-15 8:32 
AnswerRe: int **p = (int**)new int(5); Confusing !!! Pin
Richard Andrew x645-Apr-15 10:14
professionalRichard Andrew x645-Apr-15 10:14 
AnswerRe: int **p = (int**)new int(5); Confusing !!! Pin
Zabir Al Nazi Nabil5-Apr-15 11:34
professionalZabir Al Nazi Nabil5-Apr-15 11:34 

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.