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_Assignme ntOp(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!
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_Assignme
{
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
ASKER
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