- Joined
- Jun 12, 2008
- Messages
- 2
- Reaction score
- 0
i am having no success using auto_ptr as a member of a class. the code below works fine in ms vc9, but will not compile for gcc. i get the following compile error
This is something to do with calling the constructor....i dont know what it is. some insight into the problem is required!
In function `void someFunc()':
no matching function for call to `ExceptionHandler::ExceptionHandler(ExceptionHandler)'
candidates are: ExceptionHandler::ExceptionHandler(ExceptionHandler&)
ExceptionHandler::ExceptionHandler(const int&)
Code:
#include <iostream>
#include <sstream>
#include <memory>
#include <stdexcept>
using namespace std;
class ExceptionHandler: public runtime_error
{
mutable auto_ptr<stringstream> autoPtr_sstream;
public:
ExceptionHandler(const int &int_errCode):runtime_error("")
{
autoPtr_sstream.reset(new stringstream());
}
~ExceptionHandler() throw(){}
};
Code:
int main(int argc, char *argv[])
{
try
{
someFunc();
}
catch(const ExceptionHandler &e)
{
}
return EXIT_SUCCESS;
}
void someFunc()
{
throw ExceptionHandler(100);
}
This is something to do with calling the constructor....i dont know what it is. some insight into the problem is required!