File: wrong5.cc

package info (click to toggle)
duma 2.5.21-11
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,460 kB
  • sloc: ansic: 5,512; cpp: 2,205; makefile: 441; javascript: 191; sh: 129
file content (40 lines) | stat: -rw-r--r-- 598 bytes parent folder | download | duplicates (2)
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
#include <noduma.h>
#include <iostream>
#include <string>
#include <dumapp.h>

using namespace std;

class Test {
public:
  int a;
  string stdstr;

  Test() {
	a=2;
	stdstr = "test";
  }

};

int main() {
  cout << "Hello world!" << endl;

  {
  Test* pI = new Test[10];
  cerr << "Let's delete instead of delete [] " << endl;
  delete pI;
  cerr << "Did you notice?" << endl;
  }

  {
  Test* pI = new Test[10];
  cerr << "Now let's free instead of delete [] " << endl;
  free(pI);
  cerr << "Did you notice?" << endl;
  }

  cerr << "There should be 2 errors in this run" << endl;
  return 0;

}