Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

An easy template quesion

Posted on 2006-06-10
1
Medium Priority
?
216 Views
Last Modified: 2010-04-01
Hi folks,

I am new to C++ and have a question.

I have a class BST:

template <typename Datatype> class BST
{
...
...
}

BST has three data members:

Node * root (Node is defined within BST as a private class)
int size (default is 0)
queue<Datatype> aQueue (default is NULL)

How shall I write the constructor? (code below is provided, I need to add size and aQueue)

template <typename DataType>
inline BST<DataType>::BST()
: root(0)
{    
}

Thanks
0
Comment
Question by:tiger0516
[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
1 Comment
 
LVL 15

Accepted Solution

by:
efn earned 200 total points
ID: 16879278
You can initialize size the same way you initialize root.  For example:

: root(0), size(0)

A queue can't be NULL.  It is empty when constructed by default, so if that is acceptable, you don't need to do anything to initialize it.
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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

604 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