title: How to create an instance of a struct in C++?
body: <p>The issue is an <em>"Access violation writing location 0x00000000"</em> error message right after I initialize the <code>bk</code> variable to <code>NULL</code>. My guess is I should reserve memory space in advance to assign <code>NULL</code> ( something like <code>Book bk = new Book();</code> ) but I have not been able to figure out how to do it in C++ till now. </p>
  
  <h3>Book.h</h3>
  
  <pre><code>#ifndef Book_H
  #define Book_H
  
  struct _book;
  typedef _book* Book;
  
  Book CreateBook(unsigned int pageNum);
  </code></pre>
  
  <h3>Book.cpp</h3>
  
  <pre><code>#include "Book.h"
  #include &lt;iostream&gt;
  
  #ifndef Book_CPP
  #define Book_CPP
  
  using namespace std;
  
  struct _book
  {
      int pageNum;
  };
  
  Book CreateBook( unsigned int pageNum){
  
      Book bk = NULL; 
  
      bk-&gt;pageNum = pageNum;
  
      return bk;
  };
  </code></pre>