Logo Search packages:      
Sourcecode: ccmalloc version File versions  Download package

test_C++_01.cc

extern "C" {
#include <string.h>
#include <stdlib.h>
#include <strings.h>
};

class Wrong
{
protected:

  char * str;

public:

  Wrong(const char * s)
  {
    strcpy(str = new char [ strlen(s) + 1 ], s);
  }
};

class Right
:
  public Wrong
{
public:
  
  Right(const char * s) : Wrong(s) { }
  ~Right() { delete [] str; }
};

Wrong wrong("first test");
Right right("right");

int
main()
{
  Wrong a("a second test with a longer string");
  Wrong b("short string");
  (void) a; (void) b;

  return 0;
  exit(0);
}

Generated by  Doxygen 1.6.0   Back to index