Re: possibility to forbid use of "this"?
From: Ernst Murnleitner (mur-spam_at_awite.de)
Date: 01/07/04
- Next message: Ernst Murnleitner: "Re: possibility to forbid use of "this"?"
- Previous message: Gregor Rot: "pointers : segmentation fault under Linux"
- In reply to: tom_usenet: "Re: possibility to forbid use of "this"?"
- Next in thread: tom_usenet: "Re: possibility to forbid use of "this"?"
- Reply: tom_usenet: "Re: possibility to forbid use of "this"?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 7 Jan 2004 16:46:03 +0100
> That shouldn't compile - the constructor of shared_ptr taking a T* is
> explicit, so a pointer can't implicitly convert to a shared_ptr.
>
With gcc 2.95 it compiles:
// -------------------------------------
#include <iostream.h>
#include <stdlib.h>
#include <boost/shared_ptr.hpp>
class A;
typedef boost::shared_ptr<A> APtr;
class A {
public:
A(){};
virtual ~A(){};
virtual void f(){func(this); };
void func(APtr p) {cout << "func(APtr)" << std::endl;};
};
int main(int argc, char *argv[])
{
A a;
a.f();
return EXIT_SUCCESS;
}
// -------------------------------------
- Next message: Ernst Murnleitner: "Re: possibility to forbid use of "this"?"
- Previous message: Gregor Rot: "pointers : segmentation fault under Linux"
- In reply to: tom_usenet: "Re: possibility to forbid use of "this"?"
- Next in thread: tom_usenet: "Re: possibility to forbid use of "this"?"
- Reply: tom_usenet: "Re: possibility to forbid use of "this"?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|