Link to home
Start Free TrialLog in
Avatar of dauler
dauler

asked on

testing overloaded assignment operator within a class

Hello,

I am trying to create a test class to test my overloaded functions and can't seem to call the operator functions correctly.

Here is my function for the assignment operator test for my complex number program:

void ComplexTest::test_AssignmentOp(const Complex& ct)
{
      cout << "Testing complex assignemnt operator..." << endl;
      if (_complex.operator =(ct.operator =)
            cout << "Passes assignment operator test!" << endl;
      else cout << "Failed assignment operator test!" << endl;
}
How do I test that opertaor-what needs to go on the right of it.  The program works fine I am just trying to add this test class to it.  Any ideas?  Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Beer7Child
Beer7Child

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
Avatar of dauler
dauler

ASKER

Thanks beer7child(great moniker!)

That works-thank you.  However, testing the other operators such as +, - , * gives me an error message with the conditional statement.  The compiler says that conditional satements are not allowed with Complex type-any ideas?

Cam
Hi,

I'm glad you find my suggestion helpfull, and thanks for the points.

If you can post the actuall source code that is causing the compilation error
and the exact compiler message, I might be able to assist.

Thanks,
Beer7Child.