I have the below exception class.

```
class ExceptionTest : std::exception
{
public:
ExceptionTest(int value):
  m_value(value)
{
}
~ExceptionTest()
{
}
private:
ExceptionTest(const ExceptionTest& test)
{
}

int m_value;
};

```

I then use it in this way - 

```
int checkexception()
{
throw ExceptionTest(2);
}

int main()
{
try
{
    checkexception();
}
catch (ExceptionTest& exception)
{
    cout<<"haha";
}
return 1;
}

```

This works perfectly fine even though the copy constructor is private.

If you catch the exception by value it fails - 

```
int main()
{
try
{
    checkexception();
}
catch (ExceptionTest exception) --> this fails
{
    cout<<"haha";
}
return 1;
}

```

the error i get is 

```
error C2316: 'ExceptionTest' : cannot be caught as the destructor and/or copy   
constructor are inaccessible

```

I get a linker error if I do not define the copy constructor in the class

```
class ExceptionTest : std::exception
{
public:
ExceptionTest(int value):
  m_value(value)
{
}
~ExceptionTest()
{
}
private:
ExceptionTest(const ExceptionTest& test);

int m_value;
};

```

LINK : C:\Users\sumitha\Documents\Visual Studio 2010\Projects\test\Debug\test.exe not found or not built by the last incremental link; performing full link
1>main.obj : error LNK2001: unresolved external symbol "private: \_\_thiscall ExceptionTest::ExceptionTest(class ExceptionTest const &)" (??0ExceptionTest@@AAE@ABV0@@Z)
1>C:\Users\sumitha\Documents\Visual Studio 2010\Projects\test\Debug\test.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

If the above is true, we can always make the copy constructor of the exception class private, so that the caller would be forced to catch the exception by reference. I think this is happening because of "return value optimization"