|
The former is the proper way to do it (that's called a constructor initialization list).
Regards,
Nish
|
|
|
|
|
I think I am seeing this now. The one question I have is does the constructor initialization list buy you anything for primitive data types? It seems a waste for that and they would be better to initialize in the body of a constructor or in an initialization member function.
|
|
|
|
|
Only problem is when you have multiple constructors. So if your initialization list is huge, you need to copy/paste that for every constructor overload. In such cases a better solution might be to use an Init function that's called by all these constructors.
Regards,
Nish
|
|
|
|
|
The former is referred to as an initialization list. One benefit, if you need it, is improved performance. The latter is an assignment, which could cause a temporary object to be created. If the member variables you are initializing are intrinsic types (e.g., int , char ), there is no difference in performance.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
|
Aaaahhhhh.... The forum that Shall Not Be NamedTM
There's quite a few members here (including me) who left That Other Place when they sold their soul to the devil... This site was set up initially for that very reason.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Scott Meyers, in "Effective C++" says to "Prefer initialization to assignment in constructors" (Item 12)
"From a purely pragmatic point of view, there are times when the initialization list must be used. In particular, const and reference members may only be initialized, never assigned."
There is also a question of efficiency: "When a member initialization list is used, only a single string member function is called. When assignment inside the constructor is used, two are called. . . Even in the case of the lowly string type, the cost of an unnecessary function call may be significant, and as classes become larger and more complex, so do their constructors, and so does the cost of constructing objects. If you establish the habit of using a member initialization list whenever you can, not only do you satisfy a requirement for const and reference members, you also minimize the chances of initializing data members in an inefficient manner."
check out the book for the whole article--good stuff!
----------------------------------------
Please reply in the forum--my email is filtered
|
|
|
|
|
|
Is there a way in MS VC++ 6.0 and/or VS 6.0 to export a dialog (buttons, dropdowns, etc.) and import it into a VB form or vice versa? I am in a position where I have to create some screens in VB that exist in VC++. I would prefer not to have to re-make the screens, i.e. add all the buttons, listboxes, etc again.
Thanks,
Troy
|
|
|
|
|
Something *might* exist but I'm not aware of anything.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
I was thinking something probably does exist, I just don't know about it. If you do find somehting, let me know.
Thanks.
|
|
|
|
|
since you have to redo all of the "connections" ( callbacks and all that junk ) in VB, I think that it might be faster to just redo the forms in VB ...
maybe there's an .rc import in VB ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
followings are copied from VC help (in LOGFONT)
===========================
For the MM_TEXT mapping mode, you can use the following formula to specify a height for a font with a specified point size:
lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
============================
the value GetDeviceCaps(hDC, LOGPIXELSY) is 600;
so formula above is:
lfHeight=-PointSize*600/72;
if PointSize=90,
lfHeight=-90*600/72=-750.
I think the result is incorrect.
what is problem?
A nice tool for optimizing your Microsoft html-help contents.
Includeh10
|
|
|
|
|
includeh10 wrote: I think the result is incorrect.
Looks right to me: 90pt is roughly 1.25", so if an inch is 600px then 750px should give you an inch and a quarter (the correct result). Why would you think this is wrong?
----
Calvin's my hero. It used to be Shog but then I saw where he made a programming mistake and admitted it publicly. I didn't know Shog made mistakes so now he's 2nd on "The All Time Hero List" and Calvin is back at #1.
- code-frog, Calling Cookie Experts...
|
|
|
|
|
hello,
i've been using vc6 standard edition for a few years now, developing various c++ and MFC applications; i looked at microsoft's visual studio web site, and was overwhelmed by the choices. is there any downside to staying with good-old 6.0? if so, are there any recommendations regarding express versus standard versus professional versus super-extra-special? all i want to do is c++, and mfc if it'll continue to be supported (i'm having my doubts about that).
thanks,
ed
apologies if this is the wrong discussion board for this question....
|
|
|
|
|
See here.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
This questions been asked over and over again, everytime nobody ever seems to get a definative answer as everybody seems to have a different option on it.
The only reason I can see not moving from VC6 would be because of legacy code, over the last few versions Microsoft have made some quite big changes to the compiler for standards compliance, etc while no a huge biggie for small projects I wouldn't want to have to go through that much heartache of if I could help it.
The newer editions of VC include Managed C++ (very cool) so you can switch in and out of .NET whilst still using MFC or Win32 code. MFC has had a bit of a revamp in places and the compiler now supports the x64 architecture. On the downside, the IDE is now way more bloated and VS 2005 is definately slightly slower because of it.
If your doing any MFC development the Express edition isn't going to be for you, it simply isn't included in the package.
Personally, I'm running VS 2005 and theres no way I'm going back to anything less - I like it, ask somebody else and they'll tell you different
Anyways, for a full list of the differences between Visual Studio 2005 editions have a look over on MSDN[^]
Gavin Taylor
w: http://www.gavspace.com
|
|
|
|
|
Gavin Taylor wrote: ...everytime nobody ever seems to get a definative answer as everybody seems to have a different option on it.
Which makes sense. If a definitive answer was provided, it would no longer be an opinion, but a fact.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
|
thanks for all your suggestions; i'm using only a small part of stl (i should be using more), so that's not a major problem for me. i guess i'll stay with vs6 until i need features that it doesn't have, or until i need to support an OS that it doesn't support.
it also seems from your posts that mfc will be supported going forward, which is a separate issue but still good to know.
thanks for all your help!
ed
|
|
|
|
|
Hello,
I'd like to retrieve current mouse position. I don't know which API functions to call.
Can somebody help?
Thanks,
Allad
|
|
|
|
|
|
|
Allad wrote: I'd like to retrieve current mouse position.
for More detail Info try this :-
GetCursorInfo
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow cheers, Alok Gupta VC Forum Q&A :- I/ IV
|
|
|
|
|
Does anybody know how to read a tab delimited file at the same time using the '\n' as a delimiter if its encountered first.
I tried using getline(buffer, num_chars, '\t')
It works fine when i know the number of columns.
Say i had a file like
line1:Col1 Col2 Col3
line2:Col1 Col2
line3:Col1 Col2 Col3
using getline(buffer, num_chars, '\t') would return
Col1 Col2 Col3 Col1 Col2 Col1 Col2 Col3
everything in one line.
I tried defining a macro like #define tab_eol '\t'|'\n' then use it as
getline(buffer,num_chars,tab_eol) but it does not really work
Any help Please
Kelvin Chikomo
|
|
|
|