+ 3

Can we somehow create new operators?

In C++, Operator Overloading helps use existing operators for other class-specific purposes... But, is there a way to create new operators? Eg - $A to get the Transpose of a Matrix Class's Object...

27th Mar 2017, 7:48 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
16 ответов
+ 5
Sure... I will also try to complete mine by then...
27th Mar 2017, 2:53 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 4
All I want to know is that if that predefined operator list can be extended to new ones...like $ or ASCII characters from 128-255...
27th Mar 2017, 2:40 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 4
Thanks a Lot Again!
27th Mar 2017, 2:47 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 4
@Keshave Jat https://code.sololearn.com/cq24J951TxgI/?ref=app The Beta Version - Its finally ready!
14th May 2017, 3:42 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 3
@Keshave Jat So You're saying !a in C++ is meaningless?
27th Mar 2017, 2:38 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 3
And what about ++a, -a?
27th Mar 2017, 2:38 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 3
Thats not good.. :(
27th Mar 2017, 2:42 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 3
Or maybe use a different predefined operator, right...
27th Mar 2017, 2:43 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 3
Thats an awesome library...
28th Mar 2017, 1:31 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
yes there are rules of identifies so we can not create function with name $ as we have in jQuery and we can overload limited operators, so we can't do this in c++
27th Mar 2017, 2:40 PM
Keshave Jat
Keshave Jat - avatar
+ 1
c++ is object oriented programming language. so if you want transpose function then just create a new class and implement method name transport or whatever you want to use
27th Mar 2017, 2:42 PM
Keshave Jat
Keshave Jat - avatar
+ 1
https://www.tutorialspoint.com/cplusplus/cpp_overloading.htm there you will find the complete list of overloadable operators
27th Mar 2017, 2:45 PM
Keshave Jat
Keshave Jat - avatar
+ 1
ok I'll work on it and I'll post my matrix class. I think it will solve your problems. I will notify you here when code was completed
27th Mar 2017, 2:52 PM
Keshave Jat
Keshave Jat - avatar
+ 1
ok i got linear algebra library http://arma.sourceforge.net/ this library have all you need or you can change or get inspiration from it coz it is open source library
27th Mar 2017, 4:47 PM
Keshave Jat
Keshave Jat - avatar
0
there are the complete list of operators that can be overload. you are missing something that the identifiers can only be started with alphanumeric and underscore only so there is no chance of using $ as first letter of identifier
27th Mar 2017, 8:15 AM
Keshave Jat
Keshave Jat - avatar
0
yes we can overload ++ both post and pre operators in c++
27th Mar 2017, 2:43 PM
Keshave Jat
Keshave Jat - avatar