?
Solved

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

Posted on 2004-04-04
2
Medium Priority
?
323 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
nonubik earned 375 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

800 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