locked
How to hide an interface implementation ?

    Question

  • // C++/CX component.

    public interface class IResource
    {
    void Destroy( );
    };

    public ref class View sealed : public IResource
    {

    public :

    virtual void _Destroy( ) = IResource::Destroy; // Explicit.
    }

    // C# client.

    View v = new View( );

    ( ( IResource )v )._Destroy( ) // I was expected something like this to hide my method.

    v._Destroy( ) // But I can still call the method implicitly without a cast !


    Saturday, May 09, 2015 4:44 AM

Answers

  • Hi t-n-x

    I dont think its possible because when you called ._Destroy() in your IResource interface, actually interface is trying to find its implementation method in class View, and then if there the method is not public, a accessible error should be return.

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, May 11, 2015 2:45 AM
    Moderator