File: test_C%2B%2B_01.cc

package info (click to toggle)
ccmalloc 0.4.0-9
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 488 kB
  • ctags: 446
  • sloc: ansic: 4,493; sh: 523; makefile: 105; cpp: 89
file content (43 lines) | stat: -rw-r--r-- 515 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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);
}