|
From: Socha, D. F <dav...@us...> - 2003-06-07 11:39:48
|
If I had a node class (such as would be used in a linked list or a =
binary search tree) as such:
=20
class node{
public:
=20
int data; //contains the data stored in the node
=20
node* next; //pointer to the next node
=20
node(){ //default constructor
}
=20
node(int insData){ //constructor that accepts parameters
data =3D insData;
}
=20
~node(){ //destructor
}
};
=20
if i use this code later on in a program and create a new node =
dynamically using code such as:
node* root =3D new node(5);
that should alocate the memory, call the constructor, and set the data =
portion of the node to 5.
=20
the constructor that is called is the one that will assign a value to =
data not the default constructor that does nothing, right?
=20
Thanks for all of your help,
David Socha
|