Link to home
Start Free TrialLog in
Avatar of pawantestaccount
pawantestaccount

asked on

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

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;
ASKER CERTIFIED SOLUTION
Avatar of nonubik
nonubik

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial