gcc: auto_ptr as a class member function not working

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

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top