File: ref_counted.cpp

package info (click to toggle)
cgal 3.6.1-2
  • links: PTS
  • area: non-free
  • in suites: squeeze
  • size: 62,184 kB
  • ctags: 95,782
  • sloc: cpp: 453,758; ansic: 96,821; sh: 226; makefile: 120; xml: 2
file content (36 lines) | stat: -rw-r--r-- 604 bytes parent folder | download | duplicates (6)
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
#include <iostream>
#include <CGAL/Kinetic/Ref_counted.h>
struct Foo: CGAL::Kinetic::Ref_counted<Foo>
{

  ~Foo() {
    std::cout << "Foo: bye, bye." << std::endl;
  }
};

struct Bar: CGAL::Kinetic::Ref_counted<Bar>
{

  Bar(Foo::Handle fp): fp_(fp){}

  ~Bar() {
    std::cout << "Bar: bye, bye." << std::endl;
  }
  Foo::Handle fp_;
};

int main(int, char*[])
{

  Foo::Handle fp= new Foo;
  std::cout << "Clearing fp.\n";
  fp= NULL;
  fp = new Foo;
  Bar::Handle bp= new Bar(fp);
  std::cout << "Clearing fp again.\n";
  fp=NULL;
  std::cout << "Clearing bp.\n";
  bp=NULL;

  return EXIT_SUCCESS;
}