All I am doing is declaring a pointer and then checking if its pointing to anything:
#pragma once
#include <Node.h>
#include <stdio.h>
template <class NodeDataType>
class LinkedList
{
typedef Node<NodeDataType>* pNode;
private:
pNode pHead;
pNode pTail;
public:
void Add(NodeDataType* pNodeTypeData)
{
if(pHead)
{
printf("phead is initialized\n");
}
else
{
printf("phead is not initialized\n");
}
}
};
then, in main()
, I am making a new LinkedList object, and calling Add
but when i run it, it outputs pHead is initialized
?
but i never initialized it?
can someone explain it to me?
thanks
(main)
#include <stdio.h>
#include <LinkedList.h>
#include <GameObject.h>
int main(int argc, char** argv)
{
LinkedList<GameObject> meList;
meList.Add(new GameObject());
return 0;
}