Click here to Skip to main content
15,919,931 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Question under MFC... Pin
Cedric Moonen20-Mar-05 23:00
Cedric Moonen20-Mar-05 23:00 
GeneralRe: Question under MFC... Pin
NewbieStats21-Mar-05 0:44
NewbieStats21-Mar-05 0:44 
GeneralRe: Question under MFC... Pin
toxcct21-Mar-05 22:10
toxcct21-Mar-05 22:10 
GeneralConstructor in VC++ Pin
binh.pham20-Mar-05 20:57
binh.pham20-Mar-05 20:57 
GeneralRe: Constructor in VC++ Pin
_Andrew20-Mar-05 21:11
_Andrew20-Mar-05 21:11 
GeneralRe: Constructor in VC++ Pin
toxcct20-Mar-05 21:53
toxcct20-Mar-05 21:53 
GeneralRe: Constructor in VC++ Pin
Steen Krogsgaard20-Mar-05 23:53
Steen Krogsgaard20-Mar-05 23:53 
GeneralConstructor in CPP Pin
phijophlip20-Mar-05 19:43
phijophlip20-Mar-05 19:43 
Big Grin | :-D
Hello friends,

Please observe the program given below

#include <iostream.h>


class A
{
int a , b ;

public:

A();
A(int,int);
void show();
};


A::A()
{
a = 10;
b = 20;
}

A::A(int x1 , int x2)
{
x1 = a ;
x2 = b;
}


void A::show()
{
cout <<"the value of a" << a << endl;
cout <<"the value of b" << b << endl;
}

int main()
{
A obj1(11,20);
A obj2;
obj2.show();
cin.get();
return 0;
}

My question Can I call "show function" using the object "obj1".I tried to call the show function using the object obj1. I got junk values for a and b in return. Correct output is got when I call "show function" using the object obj2.


Why this is so ?

Please help.

Best Regards,
Phijo

Smile | :)
GeneralRe: Constructor in CPP Pin
jan larsen20-Mar-05 20:27
jan larsen20-Mar-05 20:27 
GeneralRe: Constructor in CPP Pin
Cedric Moonen20-Mar-05 20:28
Cedric Moonen20-Mar-05 20:28 
GeneralRe: Constructor in CPP Pin
Anonymous20-Mar-05 22:29
Anonymous20-Mar-05 22:29 
GeneralRe: Constructor in CPP Pin
David Crow21-Mar-05 4:05
David Crow21-Mar-05 4:05 
Generalcustom static control lin vc++ Pin
sanjay00720-Mar-05 18:14
sanjay00720-Mar-05 18:14 
GeneralRe: custom static control lin vc++ Pin
Tareq Ahmed Siraj20-Mar-05 18:41
Tareq Ahmed Siraj20-Mar-05 18:41 
GeneralRe: custom static control lin vc++ Pin
sanjay00720-Mar-05 18:54
sanjay00720-Mar-05 18:54 
GeneralNorthwind exercises Pin
Renjith Ramachandran20-Mar-05 15:49
Renjith Ramachandran20-Mar-05 15:49 
GeneralPacket Filtering Pin
OvermindDL120-Mar-05 15:00
OvermindDL120-Mar-05 15:00 
Questionoverloading bug in VC++6?? Pin
nm_11420-Mar-05 14:41
nm_11420-Mar-05 14:41 
AnswerRe: overloading bug in VC++6?? Pin
PJ Arends20-Mar-05 16:32
professionalPJ Arends20-Mar-05 16:32 
GeneralRe: overloading bug in VC++6?? Pin
nm_11420-Mar-05 17:44
nm_11420-Mar-05 17:44 
AnswerRe: overloading bug in VC++6?? Pin
cmk21-Mar-05 1:55
cmk21-Mar-05 1:55 
GeneralIPC - win32 Pin
mpapeo20-Mar-05 12:52
mpapeo20-Mar-05 12:52 
GeneralRe: IPC - win32 Pin
shiraztk20-Mar-05 23:36
shiraztk20-Mar-05 23:36 
GeneralRe: IPC - win32 Pin
mpapeo21-Mar-05 8:51
mpapeo21-Mar-05 8:51 
GeneralRe: IPC - win32 Pin
shiraztk21-Mar-05 19:03
shiraztk21-Mar-05 19:03 

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.