having private copy constructor and assignment operator

what are the implications of having private copy constructor and assignment operator?
It helps prevents objects from being copied and assigned to each other.
If you cant copy construct an object or do the assignment then you can only
do parameter passing by reference.

This is how the streams work in C++ - you will notice that you can only pass stream objects
by reference;

Example:

1
2
3
4
5
6
7
8
9
10
11
void func2( ostream os, int i) //function that expects an ostream by copy
{

}

int main()
{
    
    func2(cout, 2); //will create error - ostream copy constructor is private
}
  

Last edited on
Topic archived. No new replies allowed.