WTL & ATL class member variables

  • Thread starter Egbert Nierop \(MVP for IIS\)
  • Start date
E

Egbert Nierop \(MVP for IIS\)

I use these classes rather a time but never could make up a reason to decide
between declaring a member variable as a pointer or directly.
For instance

CIcon m_icon;

or
CIcon * m_icon;

The visual programming-difference is that when you use a pointer, you need
to 'new' and to 'delete' the instances. But what are the other pros/cons?

Thanks!
 
B

Bruno van Dooren

The biggest issue for me is that with the direct declaration, you don't have
to check for NULL.

i use std::string a lot, and i can choose between the direct declaration or
the pointer declaration.
it becomes kind of tedious to always do

if(NULL == ptr)
{
//do cleanup
throw ExNullPtr("ptr was NULL")
}

that's why i try to use direct declaration as much as possible. one less
problem to check.

kind regards,
Bruno.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top