Answer to Question #184113 in C++ for Sardar

Question #184113

.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


1
Expert's answer
2021-04-22T05:44:03-0400



#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS