130 likes | 243 Views
Object Oriented Programming with C++ syntax TA class. > February 2008, Amirkabir university, CS department. Provided by Amin Gheibi. Class.
E N D
Object Oriented Programming with C++ syntaxTA class > February 2008, Amirkabir university, CS department Provided by Amin Gheibi
Class • A class is a software template that defines the methods and variables to be included in a particular kind of object. The methods and variables that make up the object are defined only once, in the definition of the class. The objects that belong to a class—commonly called instances of that class—contain only their own particular values for the variables.
Implementation • It depends on programming language. Here we talk about implementation syntax in C++. • Let’s implement your design of educational system objects in C++ syntax. • Look at the board!
Inheritance: IS-A relation • The mechanism whereby one class of objects can be defined as a special case of a more general class is known as inheritance. • Special cases of a class are commonly known as subclasses of that class; the more general class, in turn, is known as the superclass of its special cases. • In addition to the methods and variables they inherit, subclasses may define their own methods and variables. They can also redefine any of the inherited methods, a technique known as overriding.
Hierarchies of Classes • Classes can be nested to any degree, and inheritance will automatically accumulate down through all the levels. The resulting treelike structure is known as a class hierarchy.
Next discussion • Talking about objects as natural building blocks
Exercise • Implement your previous model of educational system classes in C++ and instantiate some objects from them.