i am writing a program which i want to compare object and sort them....
i have a class Shape which have sub classes Triangle , Circle and Rectangle....
i have store the shapes in a Vector list.
however i have tocompare the area in each shape and sort them...
i believe one way to do this is to use the "OVERLOAD OPERATOR < "
i don't quite understand how overload operators work.
i want to re assign < so that i can use bubble sort in my vector list and compare the two object's area and then swap then...
problem i'm having:
how do i define the overload operator in my class? and how do i swap 2 object in a vector list... can someone show me a quick example pls ..thx....
i have a class Shape which have sub classes Triangle , Circle and Rectangle....
i have store the shapes in a Vector list.
however i have tocompare the area in each shape and sort them...
i believe one way to do this is to use the "OVERLOAD OPERATOR < "
i don't quite understand how overload operators work.
i want to re assign < so that i can use bubble sort in my vector list and compare the two object's area and then swap then...
problem i'm having:
how do i define the overload operator in my class? and how do i swap 2 object in a vector list... can someone show me a quick example pls ..thx....