Q:-Write a C++ program to perform String operations
i. = Equality
ii. == String Copy
iii. + Concatenation
iv. << To display a string
v. >> To reverse a string
vi. Function to determine whether a string is a palindrome
vii.To find occurrence of a sub-string. Use Operator Overloading
mediafire
i. = Equality
ii. == String Copy
iii. + Concatenation
iv. << To display a string
v. >> To reverse a string
vi. Function to determine whether a string is a palindrome
vii.To find occurrence of a sub-string. Use Operator Overloading
Code
Framework:- QT 5.5.1
Os :- Linux 64 bit(Ubuntu 14.04 LTS)
Language :- C++
Thoughts on Operator Overloading
I managed to write concise and clear code, despite the fact that I don't like operator overloading. Being a Java Programmer I prefer a.add(b) constructs as against a+b .
Thought a+b seems more logical in some cases such as of Addition of Matrices. Long Equations involving Matrices can be written way cleaner using operator overloading. Actually operator overloading is a great feature in OOP until abused!
Here are some arguments against operator overloading:-
- Its syntactical sugar.
- Easier to make mistakes.
- Often operator don't do what you expect them to do.
Download Link
Includes executables, source files and screenshots
No comments:
Post a Comment