Casting scoped pointers?

I'm having some trouble after changing to scoped pointers in our code.

Is their an easy way to cast between two ScopedPointers of a parent and a dreived class? 

Just use ScopedPointer::get() to return the underlying pointer and cast it as you used to. Just obviously don't hang on to it.

For the life of me I can't seem to use the get funtion on a ScopedPointer 


ScopedPointer<MyClassType> ptr = new MyClassType();

MyOtherClassType *ptr2 = ScopedPointer::get(ptr);


What is the correct syntax?



Basic c syntax…

ptr2 = ptr.get();

You can also use dynamic_cast


Nearly - you want the dot operator, since you're calling a function on the pointer object, not the object the pointer points to!

ScopedPointer<Foo> scopedFooPtr (new Foo());
Foo* foo = scopedFooPtr.get();




The dot operator is where I was coming a cropper,  wasn't expecting to use it at all on a pointer...thanks guys!