C++ Class Operator Overload

C++ examples for Class:Operator Overload

Description

Click the following links for the tutorial for Class and Operator Overload.

  1. The C++ Operators That Can Be Overloaded
  2. Fraction Class, == equals, << ostream operator
  3. Fraction Class Operators, plus, multiply
  4. Point Class Operators, plus and subtract
  5. Demonstrate the assignment operator on a user defined class
  6. Using Manipulators when overloading stream operator
  7. Overloading the Addition Operator, +
  8. Overloading the Postfix Operator, ++


  9. Overload Increment operator, ++
  10. Overload int() Operator, assign an object to a built-in value
  11. Conversion Operators: a constructor that takes an int and produces a Counter object.
  12. Define a custom assignment operator and avoids the same-object problem.
  13. Create string class based on char array
  14. Defining Constrained Value Types
  15. Overloading Arithmetic and Assignment Operators for Intuitive Class Behavior
  16. Overloading the Increment and Decrement Operators


  17. Making a Class Readable from a Stream
  18. Making a Class Writable to a Stream
  19. Representing a Fixed-Size Numerical Vector
  20. Implementing Fixed-Point Numbers and support all comparison operators
  21. Time class definition
  22. Create Rational Class to do arithmetic with fractions.
  23. Create Complex class to do arithmetic with complex numbers.
  24. Create set class to hold integer
  25. Use string overloaded equality and relational operators
  26. Overloading the Binary Stream Insertion and Stream Extraction Operators
  27. Create RationalNumber Class and Overload addition, subtraction, multiplication, division and relational and equality operators
  28. Create BigInteger Class and Overload multiplication, division and all relational and equality operators.
  29. Overload arithmetic, ==, !=, >> and << operators for Complex Class
  30. Date class definition with overloaded increment operators.
  31. Create Point Class and overload stream insertion and stream extraction operator functions.
  32. Implementing the % operator for the Pool class to produce the volume left after dividing one Pool object into another.
  33. Implementing the / operator for the Pool class to allow one Pool object to be divides into another.
  34. Implementing the * operator for the Pool class to pre-multiply by an integer
  35. Implementing the * operator for the Pool class to post-multiply by an integer
  36. Converting length objects, Length classes with conversion operator functions
  37. Using the Time class with an overloaded extraction operator implemented as a friend of the Time class
  38. Using the Time class with an overloaded insertion operator.
  39. Lvalues and the Overloaded Subscript Operator
  40. Overloading the Subscript Operator
  41. Using the addition operator for Pool objects with this pointer
  42. Overload addition operator for Pool objects
  43. Implementing an Overloaded Operator
  44. Implementing Operators for a Class
  45. Operator Function Idioms
  46. Increment counter variable with ++ operator, uses unnamed temporary object
  47. Increment counter variable with ++ operator, return value
  48. Increment counter variable with ++ operator
  49. Overloaded '+' operator concatenates strings for custom string class
  50. Overloaded '==' operator compares strings
  51. Overloaded ++ operator in both prefix and postfix
  52. Overloaded '+' operator adds two Measures
  53. Overloaded '+=' assignment operator
  54. Overloaded '<' operator compares two Measures
  55. Overloads assignment operator (=)
  56. Creates safe array, index values are checked before access, uses overloaded [] operator for both put and get
  57. Conversions: Measure to meters, meters to Measure
  58. Overloaded << and >> operators can work with files
  59. Overloaded << and >> operators
  60. Overloaded arithmetic operators work with type Int
  61. Overloaded '+' operator adds two times
  62. Overloaded '+=' operator concatenates strings
  63. Overloaded '-' operator subtracts two Measures
  64. Convert between ordinary strings and class String
  65. Converts from Time24 to Time12 using operator in Time24
  66. Creates array class
  67. Limitation to overloaded + operator
  68. Memory-saving String class, this pointer in overloaded assignment
  69. Creates array class, overloads assignment operator and copy constructor
  70. Overload Built-in Conversion, Conversion from a user-defined data type to a built-in data type
  71. Overload insertion and extraction operator functions in the Complex class
  72. Overload insertion operator << for cout
  73. Overload plus operator (+) for Complex class
  74. Overload the relational expression == to Complex class
  75. Overload inserter and extractor to output the coordinates and read the coordinates.
  76. Overload the cast operator from custom class to int
  77. Overloads increment and decrement for the Box class, both the prefix and postfix forms
  78. Overload new, new[], delete, and delete[] for the Box class.
  79. Overload -> so that it prevents an attempt to use a null pointer to access a member.
  80. Overload ->, a pointer to the invoking object.
  81. Overload [] to create a generic safe array type.
  82. Demonstrate the function call operator.
  83. Demonstrate operator overloading basics using the Box class.
  84. Overload the Subscripting Operator []