When we are defining class we sometimes would like to allow easily convert that class from and to previously defined-type objects (ex. int ). We can do that using conversion constructor and conversion operator: conversion constructor - it is constructor which has one parameter - type which constructor should allow to convert from. It allows to convert previously defined object of type as in constructor paramter into object of class where constructor belongs to conversion operator - it is overloaded operator type() - where type is type of object which we can convert this class object into Let's see below example for better understanding: Output of this example is: In that example in our class TestClass we are defining two conversion constructors. conversion constructor for type int (point I) conversion constructor for type string (point II) Next in main function we are invoking that constructors converting int and string types to our class TestClass type (p...
Articles based on my software engineering adventure