hi friends
Can we say that class/objects in C++ implicitly supports state based programmming?
Printable View
hi friends
Can we say that class/objects in C++ implicitly supports state based programmming?
state based programming ???? :confused: clarify your question plz
well let me explain,
Say I have a class
Class SunLight{
public:
bool state;
void set_state(bool state_value)
{
state=state_value;
}
};
Here I am have function which changes the data member value of my class. So in general I am changing the state of my class.
in C language I can do same using procedure programming but where I need to explicly declare and hold/preserve variables and manuipulate by passing those variables to function.I think this extra burden on programmer.
finally Such kind of implementation can ne implemented as shown above in C++ using classes. So can we say that for state based system my class are useful and efficient, hence the argument "C++ classes implicilty supports state based programming".
You are correct.
Objects, or classes, can hold a particular state, and, I'm probably sticking my neck out here by saying this, but encapsulation, ie. the parts of the class that you wish to hide from other classes, ideally promotes a state based architecture.
Hope that helps.