Pointer to object doesn't point to any thing !!!!!!
-
hello every body : i just want to under
stand what the pointer in linked list point to ,it is a object pointer but it seems to me that it doesn't point to any thing
class LList
{
private:
struct ListNode // Declare a structure for the list { float var1;
int var2;
ListNode *next;};
ListNode *head; // List head pointer
public:
LList( void ) { head = NULL; } // Constructor
~LList( void ); // Destructor
void appendNode( float , int );
void insertNode( float , int );
void deleteNode( float , int );void displayList( void );
}; -
hello every body : i just want to under
stand what the pointer in linked list point to ,it is a object pointer but it seems to me that it doesn't point to any thing
class LList
{
private:
struct ListNode // Declare a structure for the list { float var1;
int var2;
ListNode *next;};
ListNode *head; // List head pointer
public:
LList( void ) { head = NULL; } // Constructor
~LList( void ); // Destructor
void appendNode( float , int );
void insertNode( float , int );
void deleteNode( float , int );void displayList( void );
};Within your
struct ListNode
I would expect a
ListNode* pNext
and another
ListNode* pPrev
which must be set by one of the methods called on an instance of your
LList
to point to the next and previous structures in the list. They don't point to anything to start with, it's only when you add one to a list that they are used - they are the links in the linked list.
-
hello every body : i just want to under
stand what the pointer in linked list point to ,it is a object pointer but it seems to me that it doesn't point to any thing
class LList
{
private:
struct ListNode // Declare a structure for the list { float var1;
int var2;
ListNode *next;};
ListNode *head; // List head pointer
public:
LList( void ) { head = NULL; } // Constructor
~LList( void ); // Destructor
void appendNode( float , int );
void insertNode( float , int );
void deleteNode( float , int );void displayList( void );
}; -
hello every body : i just want to under
stand what the pointer in linked list point to ,it is a object pointer but it seems to me that it doesn't point to any thing
class LList
{
private:
struct ListNode // Declare a structure for the list { float var1;
int var2;
ListNode *next;};
ListNode *head; // List head pointer
public:
LList( void ) { head = NULL; } // Constructor
~LList( void ); // Destructor
void appendNode( float , int );
void insertNode( float , int );
void deleteNode( float , int );void displayList( void );
};Like any other uninitialized variable, an uninitialized pointer contains garbage (or, in other words, points to garbage). In the shown code,
head
is initialized withNULL
to mark the list as empty, it is responsibility ofappendNode
(orinsertNode
) implementation to allocate a freshListNode
and makehead
pointing to it.Veni, vidi, vici.
-
Like any other uninitialized variable, an uninitialized pointer contains garbage (or, in other words, points to garbage). In the shown code,
head
is initialized withNULL
to mark the list as empty, it is responsibility ofappendNode
(orinsertNode
) implementation to allocate a freshListNode
and makehead
pointing to it.Veni, vidi, vici.
i saw ur name in top experts Great.! i've a question and i posted it in forum but i didnt get correct answer so i want too ask u that question as u r an expert please give me answer sorry for writing here i'm waiting for ur reply Thanks in advance HOW TO WRITE SQL QUERY IN XML? please explain about it i seen an article in this forum but it not help me lot of errors in it Thanks in advance
-
i saw ur name in top experts Great.! i've a question and i posted it in forum but i didnt get correct answer so i want too ask u that question as u r an expert please give me answer sorry for writing here i'm waiting for ur reply Thanks in advance HOW TO WRITE SQL QUERY IN XML? please explain about it i seen an article in this forum but it not help me lot of errors in it Thanks in advance
-
Actually I'm not an expert, neither of
SQL
nor ofXML
. However you may store data both in databases and inXML
files, each method having its pros and cons. Typically you query for data in databases usingSQL
, while useXPath
for finding them inXML
files. If you are interested in usingXML
files as data storage then you may find many many tutorial available on the web, just use Google.Veni, vidi, vici.