C++Tutorial for Beginners 30 - Data Members, a.k.a. Instance Variables

Classes are used in C++ programs as templates for creating objects; every object has, usually, not only some "methods" (subroutines) that define its behaviour, but also "instance variables" or "properties" which define its state. A human being, for example, has not only things that it can do (walk, talk, eat and so on) but also a state (mood, height, blood pressure). We can model both of these using methods and instance variables respectively.



Click here to download source code for this tutorial.