.Define a class Shape and create constant object from the class with at least one constant data member. Create object in main function from the class Shape. Also display state of the constant object in main( ) function
#include<iostream.h>
#include<conio.h>
class Shape
{
public:
int m_value;
Shape(): m_value{0} { }
void setValue(int value) { m_value = value; }
int getValue() { return m_value ; }
};
int main()
{
const Shape shape{};
shape.m_value = 5;
shape.setValue(5);
return 0;
}
Comments
Leave a comment