my class menu have a constructor: Menu(string caption, Menu *submenu=NULL, HWND MainHWND=WindowMain, bool systmenu=false)
how can i convert the submenu to address variable instead a pointer?
that constructor make me use it on these way: Menu mnuFile("&File"), mnuExit("&Exit",&mnuFile);
the address operator before the mnuFile. can i change the Menu contructor for accept it without the address operator?
(but continueing with 1 default value)
i'm sorry but what you think about: Menu(string caption, Menu &submenu=*(Menu*)NULL, HWND MainHWND=WindowMain, bool systmenu=false)
?
but i don't know compare the value.
another question: being a pointer, i can use NULL, but why not with adress operator?
Null means the pointer is not pointing to a valid object. It is not allowed to dereference a null pointer. If you do, it means the behaviour is undefined so anything could happen.
If you need to handle null I really think you should use pointers. References are not the correct tool for the job. It isn't that much of a job having to type & when you pass the object, is it?
the problem isn't the job. but.. i did that class, but after sometime i was trying to use it, but i forget the '&', the compiler give me errors, but i was not understanding them :(
that's why i must do your 1st advice and overloading the constructor. it's the best.
Menu(string caption, HMENU systemmenu, HWND window=ActivatedForm)Menu(string caption,HWND MainHWND=ActivatedForm)Menu(string caption, Menu &submenu, HWND MainHWND=ActivatedForm)
like you see, only the 3rd parameter have defult value. so no error.
i hope these information help more people that needs overloading functions