Click here to Skip to main content
15,915,845 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: text drawn with CPaintDC::DrawText disappears!!! Pin
Johan Rosengren7-Jun-04 19:43
Johan Rosengren7-Jun-04 19:43 
GeneralRe: text drawn with CPaintDC::DrawText disappears!!! Pin
kfaday8-Jun-04 2:19
kfaday8-Jun-04 2:19 
Generala interesting question about status bar Pin
boyboy7-Jun-04 16:37
boyboy7-Jun-04 16:37 
QuestionEM_SETSEL - Clearing Selection? Pin
Blake V. Miller7-Jun-04 15:37
Blake V. Miller7-Jun-04 15:37 
AnswerRe: EM_SETSEL - Clearing Selection? Pin
Ryan Binns7-Jun-04 18:02
Ryan Binns7-Jun-04 18:02 
GeneralRe: EM_SETSEL - Clearing Selection? Pin
Blake V. Miller7-Jun-04 18:14
Blake V. Miller7-Jun-04 18:14 
GeneralRe: EM_SETSEL - Clearing Selection? Pin
Blake V. Miller7-Jun-04 18:16
Blake V. Miller7-Jun-04 18:16 
QuestionStatic or nonstatic member function? Pin
Vicord Chrane7-Jun-04 15:23
Vicord Chrane7-Jun-04 15:23 
"There is only one shared copy of static data members for all objects of a given class type." (from MSDN Library)

My question is... Is there also only one shared copy of Normal member-functions (nonstatic and not-inlined, even nonvirtual) for all objects of a given class type?

Thing to consider (from MSDN Library):
"...Class member functions are treated differently, depending on whether they are declared as static. Because nonstatic functions have an implicit argument that supplies the this pointer, nonstatic functions are considered to have one more argument than static functions; otherwise, they are declared identically."
It seems have NO reason for not-inlined plus nonstatic member functions to be instanced multiple times.

I thought it would be usefull to understand this when we need to make an array of thousands objects of AClass. Lets assume the class itself contains some nonmodified member-functions to process the class data members. If the memory usage & overheads are similar then we don't have to make those functions complicated with static modifier, do we?

Example:

class AClass {
public:
	int a;
	char* b;
	BOOL c;
	//
	MyClass();		-\
	~MyClass();		 |
	...			 |
	char* Func1();		 |--> Is there any member function
	BOOL Func2(int alpha);	 |    here that better as static?
	...			 |
	int Func79();		-/
};

...
CArray<AClass,AClass> AnArray;
...
for (int i; i < AnArray.GetSize(); ++i) {
	char* temp = AnArray[i].Func1();
	...
}


If those functions have single instance, what if we change the keyword class into struct? Afterall the class data members are POD-Types and the compiler allows it! If we can spare some memories for faster access on this, so why not?
AnswerRe: Static or nonstatic member function? Pin
Ryan Binns7-Jun-04 18:05
Ryan Binns7-Jun-04 18:05 
GeneralEnumerating Internet Ports Pin
Archer2827-Jun-04 13:24
Archer2827-Jun-04 13:24 
GeneralCan't Connect to the server Pin
osal7-Jun-04 11:50
osal7-Jun-04 11:50 
Questionis application open? Pin
pnpfriend7-Jun-04 10:00
pnpfriend7-Jun-04 10:00 
AnswerRe: is application open? Pin
David Crow7-Jun-04 10:48
David Crow7-Jun-04 10:48 
AnswerRe: is application open? Pin
Archer2827-Jun-04 13:21
Archer2827-Jun-04 13:21 
GeneralCArray Pin
brdavid7-Jun-04 9:56
brdavid7-Jun-04 9:56 
GeneralRe: CArray Pin
David Crow7-Jun-04 10:33
David Crow7-Jun-04 10:33 
GeneralRe: CArray Pin
brdavid7-Jun-04 11:41
brdavid7-Jun-04 11:41 
Generalselect a single file right click menu Pin
skoizumi291107-Jun-04 9:20
sussskoizumi291107-Jun-04 9:20 
GeneralRe: select a single file right click menu Pin
David Crow7-Jun-04 10:07
David Crow7-Jun-04 10:07 
GeneralRe: select a single file right click menu Pin
skoizumi291107-Jun-04 10:20
sussskoizumi291107-Jun-04 10:20 
GeneralRe: select a single file right click menu Pin
David Crow11-Jun-04 2:04
David Crow11-Jun-04 2:04 
GeneralRe: select a single file right click menu Pin
skoizumi2911013-Jun-04 15:34
sussskoizumi2911013-Jun-04 15:34 
GeneralRe: select a single file right click menu Pin
David Crow14-Jun-04 2:32
David Crow14-Jun-04 2:32 
GeneralCreateThread and Hooks Pin
Spiritofamerica7-Jun-04 8:29
Spiritofamerica7-Jun-04 8:29 
GeneralRe: CreateThread and Hooks Pin
David Crow7-Jun-04 8:59
David Crow7-Jun-04 8:59 

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.