473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

WTL & ATL class member variables

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!

Jan 22 '06 #1
1 1139
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.

"Egbert Nierop (MVP for IIS)" <eg***********@nospam.invalid> wrote in
message news:ek**************@TK2MSFTNGP14.phx.gbl...
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!

Jan 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: qazmlp | last post by:
class base { // other members public: virtual ~base() { } virtual void virtualMethod1()=0 ; virtual void virtualMethod2()=0 ; virtual void virtualMethod3()=0 ;
19
by: Thomas Matthews | last post by:
Hi, Given a structure of pointers: struct Example_Struct { unsigned char * ptr_buffer; unsigned int * ptr_numbers; }; And a function that will accept the structure:
6
by: Ares Lagae | last post by:
Hello, I am trying to create a container the stl way, and I have a couple of questions. The code of the container in question can be found at ...
1
by: Jean Stax | last post by:
Hi ! A couple of pretty basic questions: Value types: As far as I understand, when I create value type without "new" syntax the object is considered as unutilized. Consequently, I have to...
4
by: alisaee | last post by:
plz check what i have made wrong what is requierd her is to creat class queue and class stack and run the push,pop operation . #include<iostream.h> #include<conio.h> #include<stdio.h> class...
1
by: mangalalei | last post by:
A static data member can be of the same class type as that of which it is a member. A nonstatic data member is restricted to being declared as a pointer or a reference to an object of its class. ...
6
by: Rob C | last post by:
We have a C# app that runs on the PocketPC. We are having some odd behavior reported from our users that I have been unable to recreate. It made me start to look at memory issues. One of the...
3
by: cutecutemouse | last post by:
---------------------------This is my task:-------------------------------------- There are hundred of similar classes and a large file(in processing) with thousand of instances of these classes....
3
by: Immortal Nephi | last post by:
The rule of inheritance states that you define from top to bottom. Sometimes, you want to define base class and set reference from dervied class to base class, but you violate the rule. Here is an...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.