gcc: auto_ptr as a class member function not working

Discussion in 'C Programming' started by astralboy79, Jun 12, 2008.

  1. astralboy79

    astralboy79

    Joined:
    Jun 12, 2008
    Messages:
    2
    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


    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!
    astralboy79, Jun 12, 2008
    #1
    1. Advertising

  2. astralboy79

    astralboy79

    Joined:
    Jun 12, 2008
    Messages:
    2
    where are the experts? brothers haaalp!
    astralboy79, Jun 13, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Siemel Naran

    auto_ptr<Derived> to auto_ptr<Base>

    Siemel Naran, Jan 10, 2005, in forum: C++
    Replies:
    2
    Views:
    1,552
    Dave Rahardja
    Jan 11, 2005
  2. akiriwas@gmail.com
    Replies:
    12
    Views:
    723
    fluden
    Feb 11, 2005
  3. matt.elkins@gmail.com
    Replies:
    3
    Views:
    671
    James Kanze
    Nov 30, 2007
  4. steve yee
    Replies:
    5
    Views:
    344
    Bo Persson
    Jul 1, 2008
  5. Sousuke
    Replies:
    9
    Views:
    1,144
    Bart van Ingen Schenau
    Mar 16, 2010
Loading...

Share This Page