Quantcast
Channel: Linux Programming Blog - Programming
Viewing all articles
Browse latest Browse all 5

C++ object's reference counting

$
0
0

Last update: 13.01.2009

Passing objects to methods by pointer or reference is very handy if you want to boost performance by avoiding invoking the copy constructor. Sometimes it's the only way to pass an object because it doesn't have a copy constructor or assignment operator defined. An example would be an object that has an open operating system resource that can't be safely shared.

Let's say that you are creating a class that does some low-level operation on a file. It contains a file descriptor as a field:

  1. class LowLevelFile
  2. {
  3. int fd
  4.  
  5. // [...]
  6. };

read more


Viewing all articles
Browse latest Browse all 5

Trending Articles