Re: Pasing a 'auto_ptr' to a method



On Sat, 2007-08-25 at 09:06 -0700, Jamiil Abduqadir wrote:
> I would like to pass a variable pointer that has been instantiated
> using 'auto_ptr' to a class method, however, the compiler complains
> saying that it does not recognize the method call; gives me a number
> of options, basically the list of overloaded methods. So my question
> is, what is the proper way to pass 'auto_ptr('s)' to a method?
> class MyClass{
>    private: std::string str*
>    public: 
>       MyClass(){ std::auto_ptr<std::string> str(new
> std::string("unknow"));}
>       MyMethod(const std::string& s){ str = s;} // <== Error??
>    ..........
> }
>  
> main(){
>    std::string temp*
>    std::auto_ptr<std::string> tmp(new std::string("hey!"));}
>    MyClass mc();
>    mc.MyMethod(temp); // <<-- Error??
>    ...

(1) please disable whatever it is in your email application that is
coloring the background of your email. its extremely irritating.

(2) this is not a C++ programming list.

(3) its not clear from the code sample above that you understand what
auto_ptr<> is for. The way you are using it makes absolutely no sense at
all. Your code example makes no sense either. 

(4) Why don't you outline what you are trying to accomplish, and someone
here (maybe me!) will likely help you? 







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]