你能告诉我下面/*=NULL*/
的含义吗?
CMyCla::CMyCla(CWnd* pParent /*=NULL*/)
: CDialog(CCycleTimes::IDD, pParent)
{
// Some code here
}
顺便说一下,我复制了同一行。
成功注释为
下面的syte// CMyCla::CMyCla(CWnd* pParent /*=NULL*/)
// : CDialog(CCycleTimes::IDD, pParent)
否则,评论失败为下面的样式。
/*
CMyCla::CMyCla(CWnd* pParent /*=NULL*/)
: CDialog(CCycleTimes::IDD, pParent)
*/
为什么评论操作失败?
答案 0 :(得分:10)
最有可能在类声明中指定该参数的默认值:
class CMyCla {
public:
CMyCla(CWnd* pParent =NULL);
};
现在在CMyCla :: CMyCla()的实现中不允许重新定义参数的默认值,但作者或许想提醒一下有默认值,所以他将其评论出来。
执行以下操作时:
/*
CMyCla::CMyCla(CWnd* pParent /*=NULL*/)
: CDialog(CCycleTimes::IDD, pParent)
*/
第一个结束评论(* /)结束了评论部分,因此其后的所有内容现在都取消注释:
/*<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
答案 1 :(得分:5)
评论在您的上一个案例中不起作用,因为/**/
样式注释未嵌套。你不能在另一个评论中添加一个/**/
评论。
答案 2 :(得分:1)
评论操作失败,因为编译器从第一个/*
读取到下一个*/
,忽略了包括其他/*
之间的所有内容。此外,什么尖锐的东西是正确的你不会被允许redfine那里的值,所以它可能是指针的默认值。