Click here to Skip to main content
       

C / C++ / MFC

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
GeneralRe: Is there a reason you would initialise variables like this?memberjschell28 Jul '12 - 6:14 
Philippe Mori wrote:
See my answer above. You have misunderstood the standard.

 
Yes, you are correct.
AnswerRe: Is there a reason you would initialise variables like this?mvpRichard MacCutchan25 Jul '12 - 1:52 
It's just a matter of style, although I think the first option is preferred. MSDN has this to say[^] on the matter. You may also like to check if Bjarne Stroustrup has more to offer.
One of these days I'm going to think of a really clever signature.

AnswerRe: Is there a reason you would initialise variables like this?memberGeorge L. Jackson25 Jul '12 - 7:07 
C++ FAQ by Marshall Cline says: [10.6] Should my constructors use "initialization lists" or "assignment"?
[^].
"We make a living by what we get, we make a life by what we give." --Winston Churchill

GeneralRe: Is there a reason you would initialise variables like this?memberMarkBrock25 Jul '12 - 22:45 
Thanks George Smile | :)
Mark Brock
"We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

GeneralRe: Is there a reason you would initialise variables like this?memberw-peuker26 Jul '12 - 21:30 
...and don't forget that the compiler processes the initializer list following the declaration order given in the class definition.
So you better stick to that order in the list (to prevent confusion). There are tools availabe that check this (e.g. cppcheck)
AnswerRe: Is there a reason you would initialise variables like this?memberEugen Podsypalnikov25 Jul '12 - 7:42 
// Is there any particular reason
Yes Smile | :) :
class A
{
  //..
public:
  A();
  A(int);
  A& operator=(int);
};
 
class B
{
  A m_a;
public:
  B() { m_a = 3; /*second call, after A::A()*/}
  // B() : m_a(3) /*first and last call of A::A(int)*/ {}
};
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap. Smile | :)

AnswerRe: Is there a reason you would initialise variables like this?memberMalli_S25 Jul '12 - 20:58 
The difference is that, in the first way of initialization (known as 'Initialization List'), the constructors of the initialized members are called.
 
While in the second option, all the objects get constructed before reaching the first executable statement of the constructor. Hence in the second way of initialization, the assignment operators gets called.
[Delegates]      [Virtual Desktop]      [Tray Me !]

-Malli...! Rose | [Rose]

QuestionShellExecute() launch .CHM and PDF file not work in Window 7memberAndraw11124 Jul '12 - 7:31 
Dear all,
 
HINSTANCE handle = ShellExecute(NULL, NULL, strHlpFile, NULL, NULL, SW_SHOW);
 
I create a application in MFC, it works fine in Window XP and return 42 value, but if run it in Window 7, it cannot open the .CHM or PDF file, the return code is 8.
 
What's the problem? how can I solve issue?
 
I try to use system() to launch .CHM or PDF file, it works fine in both Window XP and Window 7, but it has MS-DOS black screen there, how can I let MS-DOS not shown?
 
Thank you very much!
QuestionRe: ShellExecute() launch .CHM and PDF file not work in Window 7memberDavidCrow24 Jul '12 - 8:06 
Andraw111 wrote:
What's the problem?
Something memory related.
 
Andraw111 wrote:
how can I solve issue?
What is the value of strHlpFile?

"One man's wage rise is another man's price increase." - Harold Wilson

"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous


AnswerRe: ShellExecute() launch .CHM and PDF file not work in Window 7memberAndraw11124 Jul '12 - 8:13 
Thanks for reply,
 
strHlpFile is the full path to .pdf file or .CHM file.
 
If it's about memory issue, how can I solve it?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 24 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid