Hi,
I am used to initialize pointers in my classes the following way:


Qt Code:
  1. XX::XX():
  2. bla(new something(this)),
  3. bla2(new someotherthing(this))
  4. {
  5. //
  6. }
To copy to clipboard, switch view to plain text mode 

i.e. using 'new' to initialize member pointers in my classes. Usually Qt gui classes.
With the gcc this works just fine, visual studio gives me a warning and I hate code, which does not compile cleanly without warnings.

Now I wonder whether above code is acceptable and the VS warning is only a Microsoft marketing thing to support their 'managed' stuff, or really bad style. I searched the internet, but did not find much about above problem.

The only problem I see is that if the construction of XX fails and an exception is thrown I have a memory leak since the destructor isn't called. However, with all the code I wrote up to date, I don't see this as problem, in all cases the program would have to terminate anyways.

Something I overlook? Any comments?