locked
How we can declare constructor with Interface parameter in C++/CX

    Question

  • Hi all how to implement windows runtime component constructor with Interface parameter?

    Sample:

    MyRuntimeComponent(IMediaPlayer player)

    {

    }

    public interface class IMediaPlayer 

    {

    void paly();

    };

    Thanks....

     

    Pallam Madhukar Windows Phone Developer

    Wednesday, August 13, 2014 9:22 AM

Answers

  • constructors arent part of the interface. so you only need tyi implement the method in your class

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Wednesday, August 13, 2014 9:52 AM
  • Thats not possible you cannot declare object of Abstract classes its the violation of inheritance you can inherit the class with an interface but cannot create object of interface (Abstract class).
    Wednesday, August 13, 2014 12:51 PM

All replies

  • constructors arent part of the interface. so you only need tyi implement the method in your class

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Wednesday, August 13, 2014 9:52 AM
  • Hi Dave Smits, I am trying to create constructor in class only, I want to declare interface object as class constructor parameter. Please can you suggest me?

    Pallam Madhukar Windows Phone Developer

    Wednesday, August 13, 2014 10:00 AM
  • Thats not possible you cannot declare object of Abstract classes its the violation of inheritance you can inherit the class with an interface but cannot create object of interface (Abstract class).
    Wednesday, August 13, 2014 12:51 PM