wong83
asked on
Quickie Dynamic memory
Hello Friends,
this is my sample code.
#include <iostream.h>
class Node
{
public:
Node(int);
private:
int data;
Node * next;
};
Node::Node(int n)
{
int x;
x=n;
}
void main()
{
int nod;
cout << "Enter node";
cin >> nod;
Node *Head;
Head = new Node(nod);**************** *******
}
the line marked with ***'s
after i compile and run this say i enter 3 for nod.
does this mean something like Head[3].
i'm trying to ask the user the number of nodes he wants and then create them dynamically.
is this correct?
Thank you .
Wong
this is my sample code.
#include <iostream.h>
class Node
{
public:
Node(int);
private:
int data;
Node * next;
};
Node::Node(int n)
{
int x;
x=n;
}
void main()
{
int nod;
cout << "Enter node";
cin >> nod;
Node *Head;
Head = new Node(nod);****************
}
the line marked with ***'s
after i compile and run this say i enter 3 for nod.
does this mean something like Head[3].
i'm trying to ask the user the number of nodes he wants and then create them dynamically.
is this correct?
Thank you .
Wong
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks n_fortynine.
You're welcome. Does 83 in your username imply anything? It's my year of birth =).
ASKER
It was mine too about 4 yrs ago . i've had that(usrname) for a long time so i decided to keep it probably because i don't have to waste a lot of my memory blocks. Thank you for your help.
So it would not be correct for Head[3]. I guess you're trying to build a linked-list-like structure???