[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppOverloadMultiply
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppOverloadMultiply
(C++) Overloading the multiplication operator
Operator overloading on the multiplication * operator.class Test { public: int value; const Test operator*(const Test& test) const { Test result; result.value = test.value * value; return result; } }; int main() { Test testA; testA.value = 8; Test testB; testB.value = 8; Test testC = testA * testB; assert(testC.value==64); return 0; }
- include <assert.h>
Topic links
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
