PART 2
1.7 Object Oriented Language
Object-oriented programming is not the right of any particular languages. Like structured programming, OOP concepts can be implemented using languages such as C and Pascal. However, programming becomes clumsy and may generate confusion when the programs grow large. A language that is specially id designed to support the OOP concepts makes it easier to implement them.
The languages should support several of the OOP concepts to claim that they are object-oriented. Depending upon the features they support, they can be classified into the following two categories
: 1. Object-based programming languages, and
2. Object-oriented programming languages
.
Object-based programming is the style of programming that primarily supports encapsulation and object identity. Major feature that are required for object based programming are:
• Data encapsulation
• Data hiding and access mechanisms
• Automatic initialization and clear-up of objects
• Operator overloading
Languages that support programming with objects are said to the objects-based programming languages. They do not support inheritance and dynamic binding. Ada is a typical object-based programming language. Object-oriented programming language incorporates all of object-based programming features along with two additional features, namely, inheritance and dynamic binding. Object-oriented programming can therefore be characterized by the following statements:
Object-based features + inheritance + dynamic binding
1.8 Application of OOP
OOP has become one of the programming buzzwords today. There appears to be a great deal of excitement and interest among software engineers in using OOP. Applications of OOP are beginning to gain importance in many areas. The most popular application of object-oriented programming, up to now, has been in the area of user interface design such as window. Hundreds of windowing systems have been developed, using the OOP techniques. Real-business system are often much more complex and contain many more objects with complicated attributes and method. OOP is useful in these types of application because it can simplify a complex problem.
The promising areas of application of OOP include:
• Real-time system
• Simulation and modeling
• Object-oriented data bases
• Hypertext, Hypermedia, and expertext
• AI and expert systems
• Neural networks and parallel programming
• Decision support and office automation systems
• CIM/CAM/CAD systems
1.10 Simple C++ Program
Let us begin with a simple example of a C++ program that prints a string on the
simple c++ program
#include<iostream>
void main()
{
1.10.1 Program feature
Like C, the C++ program is a collection of function. The above example contain only one function main(). As usual execution begins at main(). Every C++ program must have a main(). C++ is a free form language. With a few exception, the compiler ignore carriage return and white spaces. Like C, the C++ statements terminate with semicolons.
1.10.2 Comments
C++ introduces a new comment symbol // (double slash). Comment start with a double slash symbol and terminate at the end of the line
. A comment may start anywhere in the line, and whatever follows till the end of the line is ignored. Note that there is no closing symbol.
The double slash comment is basically a single line comment. Multiline comments can be written as follows
: // This is an example of
// C++ program to illustrate
// some of its features The C comment symbols /*,*/
are still valid and are more suitable for multiline comments. The following comment is allowed: /* This is an example of C++ program to illustrate some of its feature
1.10.3 Output operator The only statement in program 1.10.1 is an output statement. The statement Cout<<”C++ is better than C.”; Causes the string in quotation marks to be displayed on the screen. This statement introduces two new C++ features, cout and <<. The identifier cout(pronounced as C out) is a predefined object that represents the standard output stream in C++. Here, the standard output stream represents the screen. It is also possible to redirect the output to other output devices. The operator << is called the insertion or put to operator.
1.10.4 The iostream File
We have used the following #include directive in the program: #include
No comments:
Post a Comment