Solved

How to use operator == overloading and copy constructor in ActiveX control ?

Posted on 2004-04-04
2
307 Views
Last Modified: 2013-11-20
Hi All,
     This question is related to the class shown below. I used the following in the interface file (.idl) for making an ActiveX control in visual c++-

[id(1), helpstring("operator == overloading")] BOOL operator== (const Test& testObj);
[id(2), helpstring("addValue()")] HRESULT addValue(unsigned int value);
...
[id(4), helpstring("Test class copy constructor")] HRESULT Test(const Test& testObj);

While compiling, the compiler gives the error that operator== not allowed and also regarding the use of Test(const Test& ..). I have to use these two methods in making a activex control. Please suggest some method, tips so that I can use all the methods of Test class.
Please reply as quick as possible as it is urgent.

Thanks in advance,
Pawan
//Test class
#include <iostream>
#include <string>
using namespace std;

class Test
{
private:
    unsigned int total;
public:
    Test();
    ~Test();
    Test(const Test& testObj);
    void addValue(unsigned int value);
    unsigned int getValue();
    bool operator== (const Test& testObj);
};

Test::Test()
{
     total = 0;
}
Test::~Test()
{
}

Test::Test(const Test& testObj)
{
    this->total = testObj.total;
}

void Test::addValue(unsigned int value)
{
    total = total + value;
}

unsigned int Test::getValue()
{
    return total;
}

bool Test::operator==(const Test& testObj)
{
    if (this->total == testObj.total)
        return true;
    else
        return false;
0
Comment
Question by:pawantestaccount
2 Comments
 
LVL 16

Accepted Solution

by:
nonubik earned 125 total points
ID: 10755771
As far as I understand, you want to expose the operator== and copy constructor of Test class through some interface (e.g. ITest). An interface does not have a constructor, nor operator overloading. You  can define instead some methods like
HRESULT isEqual (.. , BOOL *pbEqual)
HRESUTL copy(.., Test **ppTest)
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel Use VBA to get user's Mac Address for their computer 5 173
post4 challenge 28 100
zeroMAx challenge 20 103
Excel file not created as expected 7 72
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question