Solved

Please explain peculiar instantiation of class

Posted on 2013-06-12
4
253 Views
Last Modified: 2013-06-12
Please see question in attached file.
peculiar-class-instantiation.txt
0
Comment
Question by:naseeam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 39241560
The line

contArr = new ContainerObject * [totalCapacity];

Open in new window


looks a bit confusing, but if you break that down for readability (and consider the rest of the code), it is just allocating an array of pointers, i.e.

contArr // declared as 'ContainerObject **'
 = new 
ContainerObject * // the space makes this confusing
[totalCapacity]; // size of the array

Open in new window

0
 
LVL 1

Author Comment

by:naseeam
ID: 39241676
Please confirm that class ContainerObject is not getting instantiated in the following statement:

contArr = new ContainerObject* [totalCapacity];
0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 500 total points
ID: 39241690
No, the class itself isn't instantiated in that line. What is done here is that an array of the size 'total'Capacity' is allocated which consist of pointersto 'ContainerObject', i.e. 'ContainerObject*'. No single 'ContainerObject' constructor will be called
0
 
LVL 1

Author Closing Comment

by:naseeam
ID: 39241712
very well short explanation.  To the point.  The quesetion got answered.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question