CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2000
    Location
    Israel
    Posts
    141

    Non-default constructor in a COM object - how?

    I would like to translate the following class to a COM object:

    class MyClass
    {
    private:
    int m_Data;

    public:
    MyClass(int Data) : m_Data(Data) {}
    int Get() { return m_Data; }
    };



    My question is: How can I translate the parameterized constructor?


  2. #2
    Join Date
    Dec 1999
    Location
    Israel
    Posts
    2,851

    Re: Non-default constructor in a COM object - how?

    You can't. COM wasn't built to use C++. It is made easy with C++, but languages such as C, VB, VBSCRIPT, etc... have no knowledge of c++ constructors/destructors. Instead of relying on a parameterized constructor, add an Init function. That the client must call before using any other method.

    Got a question? try looking it up in MSDN first. Msdn comes with the Visual Studio, and can be found at http://msdn.microsoft.com
    ---===---
    I'm not here for the rates, but rating a post is a good way for me to know how much i helped.
    ---===---
    Daniel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured