(new MyRawBitmapFrame(this))->Show();
-
- Earned some good credits
- Posts: 109
- Joined: Fri Sep 03, 2004 9:30 am
- Location: Brescia, Italy
Sorry, but I don't understand your question. The line:
is valid C++ code. This is exactly the same as writing:
But I agree that the former is not (IMHO) good readable style.
Code: Select all
(new MyRawBitmapFrame(this))->Show();
Code: Select all
MyRawBitmapFrame *p = new MyRawBitmapFrame(this);
p->Show();
Sandro Sigala - Kynosoft, Brescia
Re: (new MyRawBitmapFrame(this))->Show();
Could you give the complete compiler log and what compiler you use?l13 wrote:error C2059: syntax error : 'new'
can anyone explain to me what that line is all about?!
This is not really an error, as it is valid C++ code, though bad style...
The code simply creates an instance on the heap, but omits storing a pointer to is. Normaly you don't want that as this implies that you won't be able to access the instance after the call. It's "bad style" you can't even delete the instance. One might argue now that when using wxWidgets you don't need to delete the instance yourself, as long as it derived from wxObject, which would lead to deleting it "automatically" once the library exits. Still, IMHO, one shouldn't do that unless you're really sure that you'll never need access to the instance and that you won't be getting memory leaks doing so...
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda