title: Access violation reading location 0xCDCDCDD1
body: <p>I am using Visual Studio 2013. I am getting the <code>Access violation reading location 0xCDCDCDD1</code> error. References from <a href="http://en.wikipedia.org/wiki/Magic_number_%28programming%29" rel="nofollow noreferrer">Wikipedia: Magic Numbers</a>, <a href="http://www.cplusplus.com/forum/general/38440/" rel="nofollow noreferrer">here</a>, and <a href="https://stackoverflow.com/questions/17993591/c-access-violation-reading-location-0xcdcdcdcd-error-on-calling-a-function">this question</a> tell me that I am using an uninitialized pointer. I think the problem is with the <code>malloc</code> function I'm using, although I did refer to the <a href="http://www.cplusplus.com/reference/cstdlib/malloc/" rel="nofollow noreferrer">CPlusPlus</a> doc before using it.</p>
  
  <p>My code:</p>
  
  <pre><code>#include "SingleNode.h"
  #include "SingleList.h"
  #include &lt;iostream&gt;
  SingleList::SingleList() {}
  SingleList::~SingleList() {}
  ...
      void SingleList::addHead(int value){
      ISingleNode *temp1 = (ISingleNode *)malloc(sizeof(SingleList));
      head = NULL;
      temp1-&gt;setValue(value);
      temp1-&gt;setNext(head-&gt;getNext());
      if (!head-&gt;getNext())
      {
          head = temp1;
      }
      else
      {
          temp1-&gt;setNext(head-&gt;getNext());
          head = temp1;
      }
  }
  
      ...
  </code></pre>
  
  <p>The error is in the line <code>temp1-&gt;setValue(value);</code></p>
  
  <p>The <code>setValue(int value)</code> function is included from here:</p>
  
  <pre><code>#include "SingleNode.h"
  SingleNode::SingleNode() {}
  SingleNode::~SingleNode() {}
  void SingleNode::setValue(int value){
      this-&gt;value = value;
  }
  int SingleNode::getValue(){
      return value;
  }
  ISingleNode * SingleNode::getNext(){
      return next;
  }
  void SingleNode::setNext(ISingleNode * next){
      this-&gt;next = next;
  }
  </code></pre>
  
  <p>SingleNode.h:</p>
  
  <pre><code>#pragma once
  #include "Interfaces01.h"
  class SingleNode :public ISingleNode{
  private:
      int value;
      ISingleNode * next = NULL;
  public:
      SingleNode();
      ~SingleNode();
      void setValue(int value);
      int getValue();
      ISingleNode * getNext();
      void setNext(ISingleNode * next);
  };
  </code></pre>
  
  <p>SingleList.h:</p>
  
  <pre><code>#pragma once
  #include "Interfaces01.h"
  class SingleList :public ISingleList{
  private:
      int value;
      ISingleNode * head=NULL;
      ISingleNode * temp=NULL;
      ISingleNode * next=NULL;
      ISingleNode * temp1;
  public:
      SingleList();
      ~SingleList();
      ISingleNode * getHead();
      void setHead(ISingleNode * head);
      void addHead(int value);
      void orderSort2();
      void orderSort3();
      void sequenceOrderSort();
      void reverse();
      ISingleNode * swap(ISingleNode * head, int k);
      ISingleNode * get_node(ISingleNode * head, int k);
  };
  </code></pre>
  
  <p>On breaking at the line, the debugger is showing me the following values:</p>
  
  <p><img src="https://i.stack.imgur.com/zSY6f.png" alt="Visual Studio 2013 debug values at breakpoint"></p>