title: Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) Error : while using pointer inside class
body: <p>I'm using visual studio , with this code it gives me an "<strong>Assertion failed</strong>" message .
  I have class (C) which have an integer pointer in it with regular set and print methods ,<br>
  This is my code : </p>
  
  <pre><code>class C
  {
      int*   p;
  public:
      void print();
      void set_value(int);
      int get_value();
      C();    // default cinstructor
      C(int); //constructor with parameters (overloading constructor)
      ~C();
  };
  
  int C::get_value() {
      return *p;
  }
  
  void test(C ob1) {
      ob1.print();
  }
  
  C::~C()
  {
      cout&lt;&lt;p&lt;&lt;" has been destroyed \n";
      if (p!=0)
      delete p;
  }
  
  C::C()
  {
      p=0;
  }
  
  C::C(int x)
  {
      p=new int;
      *p=x;
  }
  
  void C::print()
  {
      if (p!=0)
      cout&lt;&lt;"p = "&lt;&lt;p&lt;&lt;"\t"
          &lt;&lt;"*p = "&lt;&lt;*p&lt;&lt;endl;
      else
          cout&lt;&lt;"Empty pointer"&lt;&lt;endl;
  }
  
  void C::set_value(int x)
  {
      if (p==0)
          p = new int;
      *p=x;
  }
  void main()
  {
      C x,y(20);
      test(y);
  }
  </code></pre>
  
  <p>anyone can help ? thanks in advance .</p>