Click here to Skip to main content
16,004,882 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalworks! Pin
caykahve17-Mar-05 0:26
caykahve17-Mar-05 0:26 
GeneralNew user interface issues for my application Pin
tim63516-Mar-05 21:13
tim63516-Mar-05 21:13 
GeneralRe: New user interface issues for my application Pin
John R. Shaw17-Mar-05 6:27
John R. Shaw17-Mar-05 6:27 
GeneralTCP/IP guru - please help Pin
eli1502197916-Mar-05 21:02
eli1502197916-Mar-05 21:02 
Questionremove system menu icon from dialog? Pin
ThinkingPrometheus16-Mar-05 20:57
ThinkingPrometheus16-Mar-05 20:57 
AnswerRe: remove system menu icon from dialog? Pin
toxcct16-Mar-05 22:25
toxcct16-Mar-05 22:25 
GeneralImage Capture from Device Pin
Anand for every one16-Mar-05 20:47
Anand for every one16-Mar-05 20:47 
GeneralFriend Functions Pin
phijophlip16-Mar-05 20:29
phijophlip16-Mar-05 20:29 
Smile | :) Hello Friends,

Please observe the first c++ program

#include <iostream.h>

class ABC
{
public :

void show()
{
cout <<"inside the show function"<< endl;
}

void show2()
{
cout <<"inside the show2 function" << endl;
}

friend void showme(ABC obj );
};


void showme(ABC obj)
{
obj.show();
obj.show2();
}

int main(void)
{
ABC xyz;
showme(xyz);
return 0;

}

Here a single object xyz is as the argument and in the friend function the object call the two member functions which is defined in the class ABC.

Please observe the second c++ program

#include <iostream.h>

class ABC
{
public :

void show()
{
cout <<"inside the show function"<< endl;
}

void show2()
{
cout <<"inside the show2 function" << endl;
}

friend void showme(ABC obj , ABC obj1 );
};


void showme(ABC obj,ABC obj1)
{
obj.show();
obj1.show2();
}

int main(void)
{
ABC xyz,xyz1;
showme(xyz,xyz1);
return 0;

}

In this c++ program two objects are passed as the argument for the friend function.In the main function two objects ie xyz ,xyz1 are passed as the arguments.

Both the program shows the same output.

My question is out of two c++ program , the optimized code is which one. If not the case the two programs how can I write optimised code for the c++ program which is described above.

One more question ? object are allocated space in the memory.when define a class and it members and member functions.Does class have its own memory space as it is with object of class?

Hoping for a reply,

Yours,
Phijo

Smile | :)
GeneralRe: Friend Functions Pin
toxcct16-Mar-05 21:03
toxcct16-Mar-05 21:03 
GeneralAccess Violation Pin
Usman Arif16-Mar-05 20:26
Usman Arif16-Mar-05 20:26 
GeneralRe: Access Violation Pin
Cedric Moonen16-Mar-05 21:38
Cedric Moonen16-Mar-05 21:38 
GeneralRotate picture Pin
JAMANAKA16-Mar-05 20:09
JAMANAKA16-Mar-05 20:09 
GeneralRe: Rotate picture Pin
John R. Shaw17-Mar-05 6:52
John R. Shaw17-Mar-05 6:52 
GeneralApplictions Communication problem Pin
ReBeL34716-Mar-05 19:47
ReBeL34716-Mar-05 19:47 
GeneralRe: Applictions Communication problem Pin
John R. Shaw17-Mar-05 6:58
John R. Shaw17-Mar-05 6:58 
GeneralGetCurrentHwProfile( ) api usage Pin
brilliant10116-Mar-05 19:21
brilliant10116-Mar-05 19:21 
GeneralProblem with Multiple Instances of ActiveX Control, Please Help Pin
rdeekonda16-Mar-05 18:27
rdeekonda16-Mar-05 18:27 
GeneralHelp on Compiled HTML(CHM) Viewer Pin
anukrati16-Mar-05 18:13
anukrati16-Mar-05 18:13 
GeneralFrame comparison Pin
Francis Chau16-Mar-05 17:12
Francis Chau16-Mar-05 17:12 
Generalvirutal class and friend class Pin
phijophlip16-Mar-05 17:10
phijophlip16-Mar-05 17:10 
GeneralRe: virutal class and friend class Pin
HalfWayMan16-Mar-05 22:32
HalfWayMan16-Mar-05 22:32 
Generaldifference between virutal class and friend class Pin
phijophlip16-Mar-05 17:10
phijophlip16-Mar-05 17:10 
GeneralRe: difference between virutal class and friend class Pin
ThatsAlok16-Mar-05 18:08
ThatsAlok16-Mar-05 18:08 
GeneralRe: difference between virutal class and friend class Pin
toxcct16-Mar-05 21:31
toxcct16-Mar-05 21:31 
GeneralCreating a graph chart Pin
Anonymous16-Mar-05 16:48
Anonymous16-Mar-05 16:48 

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.