tags:

views:

102

answers:

3

Could you tell me the meaning of /*=NULL*/ below?

CMyCla::CMyCla(CWnd* pParent /*=NULL*/)
    : CDialog(CCycleTimes::IDD, pParent)
{
    // Some code here
}

And btw, i copied the same line.

Commented successfully as the syte below

// CMyCla::CMyCla(CWnd* pParent /*=NULL*/)
//  : CDialog(CCycleTimes::IDD, pParent)

Otherwise, commented failed as the style below.

/*
    CMyCla::CMyCla(CWnd* pParent /*=NULL*/)
        : CDialog(CCycleTimes::IDD, pParent)
*/

Why did the comment operation fail?

+10  A: 

Most likely in the class declaration the default value for that parameter is specified:

class CMyCla {
public:
    CMyCla(CWnd* pParent =NULL);
};

now in the implementation of CMyCla::CMyCla() redefining the default value for the parameter is not allowed, but the author perhaps wanted to remind that there is the default value, so he commented it out.

When you do the following:

/* 
    CMyCla::CMyCla(CWnd* pParent /*=NULL*/) 
        : CDialog(CCycleTimes::IDD, pParent) 
*/

the first closing comment (*/) end the commented section, so everything after it is now uncommented:

/*<CommentStart>
    CMyCla::CMyCla(CWnd* pParent /*=NULL*/<CommentEnd>)<-this is not commented
        : CDialog(CCycleTimes::IDD, pParent) <-neither is this
*/<-this closing comment can produce a compiler error
sharptooth
+5  A: 

The commenting didn't work in your last case because /**/ style comments do not nest. You can't put one /**/ comment inside another one.

Ian Ross
+1  A: 

The comment operation failed because the compiler reads from the first /* to the next */ ignoring everything in between including other /*. Also, what sharptooth is correct you would not be allowed to redfine the value there, so it's probably the default value of the pointer.

dr.manhattan