Tuesday, December 29, 2015

Example 5 : Demo Of Cin And Cout.

   >>> Example 5 : Demo Of Cin And Cout.


           void main()


                     int a=0,b=0,c=0;


                     cout << "Enter a and b ->";
                     cind >> a >> b;

                     c = a + b;
                     cout << "\n Ans = "<<c;



   >>> Output :

           Enter a and b -> 5 6
           Ans = 11

Standard Input ( cin )

   >>> The standard input device is usually the keyboard.

   >>> Cout is used in conjunction with the >>. The operator  >> is known as extraction or get-from operator. The operator must be followed by the variable that will store the data that is going to be extracted from the stream.

   >>> Cin is an object, predefined in C++ to correspond to the standard input stream. This stream represents data coming from the keyboard.

   >>> The >> takes the value from the stream object on its left $ places in the variable on its right.

   >>> For example :

                                int age;
                                cind >> age;

   >>> The first statement declares a variable of type int called age and the second one waits for an input from cin ( the keyboard) in order to store it in this integer variable.

   >>> Cin is an object, predefined in C++ to correspond to the standard input stream. This stream represents data coming from the keyboard.

   >>> The >> takes the value from the stream object on its left $ places in the variable on its right.

   >>> For example:

                              int age;
                              cin >> age;

   >>> The first statement declares a variable of type int called age, and the second one waits for an inputs from cin (the keyboard) in order to store it in this integer variable.

   >>> Cin can only process the input from the keyboard once the RETURN key has been pressed. Therefore, even if you request a single character the extraction from cin will not process the input until the used presses RETURN after the character has been introduced.

   >>> You must always consider the type of the variable that you are using as a container with cin  extractions. If you request an integer you will get an integer, if you request a character you will get a character and if you request a string of characters you will get a string of characters.

   >>> You can also use cin to request more than one datum input from the user:

                           cin >> a >> b;

                     is equivalent to :

                            cin >> a;
                            cin >> b;

   >>> In both cases the user must give two data, one for variable a and another one for variable b that may be separated by any valid blank separator: a space, a tab character or a newline.



Example 4 : Print Simple Number With It's Square.

   >>> Example 4 : Print Simple Number With It's Square.


            int main(void)

                      double x = 0.0;

                       // it's good practice to initialize all variables by assigning a value.

                       cout << " Please enter a number: ";
                       cin >> x;

                        cout << " You Entered " << x <<', whose square is " << x*x << endl;

                         return 0;


Example 3 : Print Table Of 5.

   >>> Example 3 : Print Table Of 5.

           #define N 10

            void main()
                       int i,a=5;

                                  cout<<a<<" X "<<i<<" = "<<a*i<<'\n";


      >>> Output:

                           5 * 1 = 5
                           5 * 2 = 10
                           5 * 3 = 15
                           5 * 4 = 20
                           5 * 5 = 25
                           5 * 6 = 30
                           5 * 7 = 35
                           5 * 8 = 40
                           5 * 9 = 45
                           5 * 10 = 50

Cout, Cin

   >>> Using the standard input and output library, we will be able to interact with the user by printing messages on the screen and getting the user's input from the keyboard.

   >>> The standard C++ library include the header file iostream, where the standard input and output stream objects are declared.

  Standard Output ( Cout )

   >>> By default, the standard output of a program is the screen and the C++ stream object defined to access it is cout.

   >>> Cout is actually an object, predefined in C++ to correspond to the standard output stream. A stream is nothing but the flow of data.

   >>> Cout is used in conjunction with the insertion operator, which is written as << ( two "less than" signs). It directs the contents of the variable on its right to the object on its left.

         cout <<"hello"; // prints hello on screen
         cout << 300;     // prints number 300 on screen
         cout << x;         // prints the content of x on screen

   >>> The << operator inserts the data that follows it into the stream preceding it.

   >>> In the examples above it inserted the constant string Hello, the numerical constant 300 and variable x in the standard output stream cout.

   >>> Notice that the sentence in the first instruction is enclosed between double quotes (") because it is a constant string of characters.

   >>> Whenever we want to use constant strings of characters we must enclose them between double quotes (")  s that they can be clearly distinguished from variable names. For example, these two sentence have very different results:

           cout << "Hello"; // Prints Hello
           cout << Hello;     // Prints the content of Hello variable.

   >>> The insertion operator ( << ) may be used more than once in a single statement:

           cout << "Hello, "<<" I am " << " a C++ statement";

   >>> This last statement would print the message Hello, I am a C++ statement on the screen. The utility of repeating the insertion operator (<<) is demonstrated when we want to print out a combination of variables and constants or more than one variable:

   cout << " Hello, I am " << age << " years old and my zip code is " << zip code;

   >>> If we assume the age variable to contain the value 24 and the zip code variable to contain 90064 the output of the previous statement would be:

                        Hello, I am 24 years old and my zip code is 90064

   >>> It is important to notice that cout does not add a line break after its output unless we explicitly indicate it therefore, the following statements:

              cout << "This is a sentence.";
              cout << "This is another sentence.;

   >>> Will be shown on the screen one following the other without any line break between them:

   >>> Even though we had written them in two different insertions into cout. In order to perform a line break on the output we must explicitly insert a new line character into cout.

   >>> In C++ new line character can be specified as \n (backslash,n);

                               cout << "First sentence. \";
                               cout << "Second sentence. \nThird sentence.";

            output :
                               First sentence.
                               Second sentence.
                               Third sentence.

   >>> Additionally, to add a new line, you may also use the endl manipulator.

   >>> For Example:

                                  cout << "First sentence." << endl;
                                  cout << "Second sentence." << endl;

              output :
                               First sentence.
                               Second sentence.

   >>> The endl manipulator products a newline character, exactly as the insertion of  '\n' does, but it also has and additional behaviour when it is used with buffered streams: the buffer is flushed.

Monday, December 28, 2015

Header Files

   >>> Some of these instructions come in computer files that you simply "put" in your program. Theses instructions or files are also called libraries.

   >>> To make your job easier, some of these libraries have already been written for you so that as you include them in your program you already have a good foundation to continue your construction.

 >>> There are libraries previously written for you.

   >>> The libraries are files that you place at the beginning of your program as if you were telling the computer to receive its preliminary instructions from another program before expanding on yours.

   >>> The libraries are computer files they have the extension ".h". An example would be house.h or person.h. As you see, they could have any name; when you start creating your own libraries you will give your files custom and recognizable names.

   >>> The first library we will be interested in is called iostream. It asks the computer to display stuff on the monitor's screen.

    #include iostream.h

   >>> There are usually two kinds of libraries or filers you will use in your programs: libraries that came with c++ and those that you write. To include your own library you would enclose it between double quotes like this

       #inlclude "book.h"

   >>> When you include a library that came with c++, you enclose it between < and > as follows:

        #inlucde <iostream.h>

   >>> Following this same technique, you can add as many libraries as you see fit.

   >>> Before adding a file, you will need to know what that file is and why you need it. This will mostly depend on your application. Suppose you want to write a program in which you implement mathematical operations that time you have to add Math.h header file.

Saturday, December 26, 2015

Example 2: Demo Of Macro Functions.

     >>> Demo Of Macro Functions.


             #define Sqr(x)(x*x)
             #define Three (x)(x*x*x)

                      int a = 5, b = 0;


                      b = Sqr(a);
                      cout<<"\n\n Square = "<<b;

                      b = Three(a);
                      cout<<"\n\n Three = "<<b;


   >>> Macros suffer from four problems in C++> The First is that they can be confusing if they get large because all macros must be defined on one line. You can extend that line by using the backless character (\), but large macros quickly become difficult to manage.

   >>> This second problem is that macros are expanded in-line each time they are used. Thus means that if a macro is used a dozen times the substitution will appear 12 times in your program rather than appear once as a function call will.

   >>> On the other hand, they are usually quicker than a function call because the overhead of a function call is avoided.

   >>> The fact that they are expanded in-line leads to the third problem which is that the macro does not appear in the intermediate source code used by the compiler and therefore is unavailable in most debuggers.

Macro Functions

   >>> The #define directive can also be used to create macro functions.

   >>> A macro function is a symbol created using #defines and that takes an argument much like a function does. The preprocessor will substitute the substitution string for whatever argument its given.

   For Example, You can define the macro TWICE AS

        #define TWICE(x)                ((x) * 2)

        and then in your code you write

       The entire string TWICE(4) will be removed and the value 8 will be substituted!

   >>> When the pre compiler sees the 4, it will substitute ((4) * 2), which will then evaluate  to 4 * 22 or 8.

   >>> A macro can have more than one parameter and each parameter can be used repeatedly in the replacement text. Two common macros are MAX and MIN:

    #define MAX(x,y) ((x) > (y) ? (x) : (y))
    #define MIN(x,y) ((x) > (y) ? (x) : (y))

   >>> Note that in a macro function definition the opening parenthesis for the parameter list must immediately follow the macro name with no spaces.

   >>> The preprocessor is not as following of white space as in the compiler.

   >>> If you were to write
           #define MAX (x,y) ((x) > (y) ? (x) : (y))

  and then tried to use MAX like this,

        int x = 5, y = 7, z;

        z = MAX (x,y);

  the intermediate code would be
        int x = 5, y = 7, z;
        z = (x,y)  ((x) > (y) ? (x) : (y)) (x,y)

   >>> A simple text substitution would be done rather than invoking the macro function.

   >>> Thus, the token MAX would have substituted for it (x,y)  ((x) > (y) ? (x) : (y)) and then that would be followed by the (x,y) which followed MAX.

   >>> By removing the space between MAX and (x,y), however, the intermediate code becomes:

           int x = 5, y = 7, z;
           z = 7;

Monday, December 21, 2015


   >>> The preprocessor looks for preprocessor construction, each of which begins with a pound symbol (#).

   >>> Using #define 

   >>> The #define command defines a string substitution. If you write #define BIG 512.

  >>> You have instructed the pre-compiler to substitute the string 512 wherever it sees the string BIG. This is not a string in the C++ sense. The characters 512 are substitute in your source code wherever the token BIG is seen. A token is a string of characters that can be used wherever a string or constants or other set of letters might be used.

   >>> With the use of above code you are going to define a Constant Value.

What is a compiler?

   >>> A computer cannot understand the spoken or written language that we humans use in our day to day conversations and likewise, we cannot understand the binary language that the computer uses to do it's tasks.

   >>> It is therefore necessary for us to write instructions in some specially defined language  in this case C++, which we can understand then have that very precise language converted in the very terse language that the computer can understand. This is the job of the compiler.

   >>> A C++ Compiler is itself a computer program whose only job is to convert the C++ program from our to form to a form the computer can read and execute.

   >>> The original C++ program is called the "Source code", and the resulting compiled code produced by the compiler is usually called an "object file".

   >>> One or more object files are combined with predefined libraries by a linker sometimes called a binder, to produce the final complete file that can be executed by the computer.

   >>> A library is a collection of pre - compiled "object code" that provides operations that are done repeatedly by many computer programs.

   >>> Any good compiler that you purchase will provide a compiler but an editor a debugger, a library and a linker. On-line documentation and help files are usually included and many compilers have tutorial to walk you through the steps of compiling, linking and executing your first program.


   >>> The comments indicate that the compiler should ignore everything following it.

   >>> This allows you to add English explanations to what might otherwise be confusing code.

   >>> You have the freedom to comment your code as much as you like some programmers write code with no comments at all; others write several lines of comments for each line of C++ code. It's all up to you.

   >>> There are  types of comments. Single line comment and Multi line comment.

   >>> To write a single line comment on one line, type two forward slashes // and type the comment. Anything on the right side of both forward slashes would not be read by the compiler. T

   >>> To write a a multi line comment you can start it with a forward slash / followed by an asterisk *, write the comment. To end the comment, type and asterisk * followed by a forward slash /.

Let's Start Now C++ Stuffs.

  >>> Example 1: A simple Program which prints "Get Logic For C++" On screen.

                            // First Program:

                                                          void main()

                                                                     Cout<<"Get Logic For C++";

                              OutPut : Get Logic For C++

   >>> Let's take a look at each line of code:

    >>> I thingk you all know why I add conio.h header file because i want to use two functions of it clrscr() which will clear the screen and getch() which waits to take the input form the user.

            //First Program
                      >>> It's comment line.

      #include <iostream.h>

               >>> This line is read " Pound include i - o - stream dot h".

               >>> The effect of this line is to essentially "copy and paste: the entire the file iostream.h into your own file at line. So you can thing if this syntax as replacing the line #include <iostream.h> with the contents of the file iostream.h.

    #inlcude is known as a Preprocessor directive. 

>>> Where is the file iostream.h?

   >>> This is located somewhere in your include path. The path indicates the directories on your computer in which to search for a file if the file is not located in the current directory.

>>> Why do I need include iostream.h?

   >>> In this case, iostream,h is a file containing code fir input/output operations. You need to include iosteam.h so that the compiler knows about the word cout which appears a couple of lines below.

     void main() {

   >>> Every c++ program must have what is known as main function.

   >>> when you run the program the program will go through every line of code in the main function and execute it, If your main is empty the your program will do nothing.

   >>> There are essentially four parts to a function definition. They are the return type function name, the parameter list and the function body in that order.

   >>> In our program return type is void which means that this function will not return any value at all.

      >>> You Can Also Write..

                                       int main ()
                                              return 0;

  >>> In this case:

          return type: int
          function name: main
          parameter list: ()
          function body: {.....}

                    For now, the important thing to remember is that the function body is the part enclosed in {....} ("curly braces"). The { indicates the beginning of the function and the } indicates the end of the function.

   >>> cout<<"Get Logic For C++";

          >>> This is the line that prints out the text string, "Get Logic For C++". You can print out any series of text string by separating them with <<.


Tuesday, December 15, 2015

Object Oriented VS Structure Paradigms

   >>> Different people will see the question in a different light. Object - Oriented programming in its pure form allows you to design classes of objects and then create instances of those classes.

   >>> A class is basically a "template" for the object in that the class knows what kinds of things the object needs to know about (attributes) and what kinds of things the object does (methods).

   >>> when you use this class template to instantiate or create an instance of an object you basically cause a new object represented by that class to exist in the scope of your program.

   >>> The developer can think about what attributes an object needs to now about and how the object needs to act those attributes. The System them tracks Much of the detail involving interactions of objects and manages much or all of the "gory details" of memory management etc.

   >>> Structured programming is mainly a way of breaking a problem into routines.

   >>> In structure paradigms primary focus in on functions.

   >>> First pick out the major tasks that need to be accomplished and these tasks become modules within each task or module identify components or building blocks and they become functions. It emphasizes functionality and does not stress data. It is particularly appropriate for applications that have a lot of independent functions that do not interact much.

   >>> In contrast to that object - oriented designs work well at a  higher level of abstraction. They facilitate the designing of modules decomposing a problem from the top level down.

   >>> At the point at which you have identified the object interfaces ( based on the data structures) and you start designing the code to support them within the modules it is usual to switch to a structured design.

   >>> In it problem is viewed as a list of instructions a sequence of things to be done such as reading, calculating & printing.

   >>> Structured techniques may on projects with 100,000 lines of source code or more Object  - Oriented techniques seem to be a better solution for the coherent design of large projects.

   >>> OOP languages also usually support inheritance which means that you can define general objects that have basic features common to whole sets of objects then build upon those generic definitions to create more specific objects from them.

   >>> For instance, if you have a generic object for a Christmas tree decoration it might have characteristic like weight and color. You could then subclass this general definition to make new classes for light strands, garlands and glass bubbles each if which would have the basic weight and color but would add new attributes and methods that would further define these new subclass of objects.

   >>> Simple tasks are usually much better accomplished through structured programming.

   >>> But maintenance of a large software system is tedious and costly.

Data Hiding / Information Hiding

   >>> As encapsulation bind data and methods together data hiding restrict sensitive data accessing to the system.

   >>> An encapsulation tells, the data is not accessible to the outside world and only those functions which are wrapped in the class can access it. These functions provide the interface between the object's data and the program. This insulation on the data from direct access by the program is call data hiding.

   >>> Insulation of data from direct access by the program.

   >>> It is also achieved by using access by the program.

   >>> It is also achieved by using access modifiers i.e. Private, Protected and Public.



   >>> Polymorphism means the ability to take more than one form.

   >>> One name many forms.
   >>> One interface multiple methods/ways.

   >>> An operation may exhibit different behaviours in different instances. The behaviour depends on the data types used in the operation.

    >>> Example:
                           void add (int a, int b)
                           void add (int a, int b, int c)
                           int add (double a, double b)
                           cout << add(5,2)
                           cout << add(5,2,3)
                           ans = add(2,3,4,5)
                           cout <<ans

   >>> Polymorphism is the ability of behaviour to vary based on the conditions in which the behaviour is invoked that is two or more methods as well as operators ( such as +, -, *  among others) can fit to many different conditions.

   >>> For Example, if a Dog is commanded to speak() this may elicit a bark; if a pig is commanded to speak() this may elicit on oink. This is expected because Pig has a particular implementation inside the speak() method. The same happens to class Dog. Considering both of them inherit speak() from animal this is an example of Overriding Polymorphism.

   >>> Another good example is about Overloading Polymorphism a very common one considering operators like "+". Once defined an operator used to add numbers given a class number and also given two other classes that inherits from number such as Integer and Double.

   >>> Any programmer expect to add two distances of Double or two instances of Integer in just the same way and more than this: Any programmer expects the same behaviour to any number. In this case the programmer must overload the concatenation operator "+", by making it able to operate with both Double and Integer instances.

   >>> The way it is done varies a little bit from one language to another and must be studied in more details according to the programmer interest.

   >>> Most of the OOP languages support small differences in method signatures as polymorphism. It's very useful once it improves code readability to enable implicit conversions to the correct handling method when apply add() method to integers  like in add(1,2) or to strings like in add("foo","bar") since the definitions of these signatures are available. In many OOP languages such methods signature would be respectively very similar to add(int a int b) and add(String a String b). This is an example of Parametric Polymorphism. The returned type and used modifiers of course depend on the programmer interest and intentions.

   >>> Polymorphism is extensively used in implementing Inheritance.

   >>> There are basically two types of Polymorphism. Compile time (also knows as early binding) and Run time (also knows as late Binding, Dynamic Binding) Polymorphism.

   >>> In compile time polymorphism object know about itself at compile time.

   >>> Overloading is a compile time polymorphism

   >>> In Overloading method should have same name with different arguments.

   >>> Simple example of overloading is (as given example) if you have scenario in which you want do Add of two or three number what ever user will pass. So you can create two methods with same name "Add" and assign 2 and 3 arguments into it.

   >>> In Run Time Polymorphism, Object does not know about itself at compile time it assigns all the properties and methods at runtime.

   >>> Dynamic Binding means that code associated with a given procedure call in not known until the time of the call at run - time.

   >>> Overloading or inheritance -based polymorphism are kind of polymorphism.

   >>> Simple and very common example I am talking about above figure a class shape which is inherited to Triangle, Square and Circle classes.

   >>> Shape class has a method name as "Draw" which will definitely inherited to all inherited class.

   >>> Now, if you declare a variable of shape class and initialize it with any of the inherited class it will call the method of inherited class.

Monday, December 14, 2015

Data Abstraction

   >>> Abstraction refers to the act of representing essential features without including the background details or explanations.

   >>> Abstraction is "the process of identifying common patterns that have systematic variations; an abstraction represents the common pattern and provides a means for specifying which variation to use".

   >>> To implement real world entity into program. Class uses the concept of abstraction.

   >>> Simplifying complex reality by modelling classes appropriate to problem.

   >>> Abstraction is a process that involves identifying the crucial behaviour of an object and eliminating irrelevant and tedious details.

   >>> Classes use the concept of abstraction and are defined as a list of abstract attributes.

   >>> Simplifying complex reality by modelling classes appropriate to problem and working at the most appropriate level of inheritance for a given aspect of the problem.

   >>> An inheritance tree can grow quite large.

   >>> When the Mammal and Cat classes are complete other mammals such as dogs (or lions,tigers and bears ) can be added quite easily. The Cat class can also be a superclass to other classes.

   >>> For example, it might be necessary to abstract the Cat class further to provide classes for Persian cats, Siamese cats and so on. Just as with Cat the Dog class can be the parent for GermanShepherd and Poodle ( See Figure Below ). The power of inheritance lies in its abstraction and organization techniques.

   >>> Note that the classes GermanSheherd and poodle both inherit from Dog each contains only a single method. however, because they inherit from Dog, they also inherit from Mammal. Thus, the GermanSpherd and Poodle classes contain all the attributes and methods included in Dog and Mammal as well as their own.

   >>> An abstract class is parent class that allows inheritance but can never be instantiated.

   >>> Abstract classes contain one or more abstract methods that do not have implementation. Abstract classes allow specialization of inherited classes.

   >>> Take an example of inheritance example; in that page I mention one example of shape class, rectangle class, circle class etc. The shape is an abstract class and provides common characteristics.

   >>> In the real world you never calculate the area or perimeter of a generic shape you must know what kind of geometric shape you have because each shape (eg. square, circle, rectangle etc ) has its own area and perimeter formulas. 


   >>> In the real world there are many objects that can be specialized. We know the children have some characteristics are common to their parents. Child depends face, features, nature, symptoms etc. In OOP, a parent class can inherit its behaviour and state to children classes.

   >>> Inheritance is the process by which objects can acquire the properties of objects of other class.

   >>> In some cases, a class will have "Subclasses", more specialized versions of  a class.

   >>> In OOP, inheritance provides re - usability, like, adding additional features to an existing class without modifying it.

   >>> Classes that serve as a basis for new classes are called base or super or parent classes.

   >>> Classes derived from base classes are called derived or sub or child classes.

   >>> Inheritance represented by a is - a relationship.

   >>> Derived classes inherit all the fields, properties, methods, and events defined in the base class. This means you can develop and debug a class ones and then reuse it as the basis for other classes.

   >>> The most common real world sample to explain inheritance is the geometric shapes object model. Squares, circles, triangles, rectangles, pentagons, hexagon, and octagons are geometric shapes. The following figure shows a sample set of geometric figures:

   >>> The concept of generalization in OOP means that an object encapsulates common state and behaviour for a category of objects.

  >>> The general object in this sample is the geometric shape. Most geometric shapes have area, perimeter and color.

   >>> The concept of specialization in OOP means that an object can inherit the common state and behaviour of a generic object; however each object needs to define it's own special and particular state a behaviour. In above figure, each shape has its own color. each shape has also particular formulas to calculate its area and perimeter.

   >>> Inheritance makes code elegant and less repetitive.

   >>> If we know that all shapes have color should we program a color attribute for each shape? The answer is no! Would it be a better idea to create a shape class that has a color attribute and to make all the specialised shapes to inherit the color attribute? The answer is yes!

   >>> A shape parent class and a derived class for each specific shape. The following UML class diagram shows the set of classes needed to model the geometric shapes sample. Observe the field, properties and methods for each class:

   >>> For example 2, say you have a Dog class and a Cat class and each will have an attribute for every eye color. In an Object Oriented design, the color attribute could be moved up to a class called Mammal along with any other common attributes and methods. In this case, both dog and cat inherit from the Mammal class as shown in figure below.

   >>> The Dog and Cat classes both inherit from Mammal. This means that a Dog class actually has the following attributes:
                              eyeColor                       // inherited from Mammal
                              barkFrequency             // defined only for Dogs

   >>> In the same vein, the Dog object has the following methods:

                             getEyeColor                 // inherited from Mammal   
                             bark                               // defined only for Dogs

   >>> When the Dog or the Cat object is instantiated, it contains everything in its class as well as everything from the parent class, Thus, Dog has all the properties of its class definition as well as the properties inherited from the Mammal class.


   >>> Storing data and function in a single unit (class) is encapsulation.

   >>> Binding the data and code to access that data. Encapsulation only refers to a container, which has a data and its related function in it.

   >>> Classes provide one of the most common ways to encapsulate items. Data cannot be accessible to the outside world and only those functions, which are stored in the class can access it.

   >>> Encapsulation is the the ability to contain and control the access to a group of associated items.

   >>> The data is not accessible to the outside world and only those functions, which are wrapped in the class can access it. These functions provide the interface between the objects's data and the program.

   >>> Encapsulation also allows you to control how the data and procedures are used. You can use access modifiers such as private or protected to prevent outside procedures from executing class methods or reading and modifying data in properties and fields.

   >>> You should declare internal details of a class as private to prevent them from being used outside your class; this technique is called data hiding.

   >>> Rememberer that encapsulation means that the attributes (data) and the behaviours (code) are encapsulated in to a single object.

Superclasses and Subclasses

   >>> The superclass, or parent class, contains all the attributes and behaviours that are common to classes that inherit from it.

   >>> For example, in the case of the Mammal class, all mammals have similar attributes such as eyeColor and hairColor as well as behaviours such as generateInternalHeat and growHair. All mammals have these attributes and behaviours, so it is not necessary to duplicate them down the inheritance tree for each type of mammal.

   >>> Thus, the dog and cat classes inherit all those common attributes and behaviours from the mammal class., The class is considered the superclass of the dog and the cat subclasses, or child classes.

   >>> Inheritance provides a rich set of design advantages. When you're designing a cat class, the mammal class provides much of the functionality needed. By inheriting from the mammal object, cat already has all the attributes and behaviours that make it a true mammal. To make it more specifically a cat type of mammal, the cat class must include  any attributes or behaviours that pertain solely to cat.

   >>> Subclasses can also add new members.

   >>> In fact, inheritance is an "is - a relationship"

   >>> To create a subclass is Specialization, to factor out common parts of derived classes into a common base ( or parent) is generalization. 

Saturday, December 12, 2015

Message Passing

   >>> " The process by which an object sends data to another object or ask the other object to invoke a method."

   >>> Also known to some programming languages as interfacing.

   >>> A message for an object is a request for execution of a procedure, and therefore will invoke a function in the receiving object that generates the desired result. Message passing involves specifying the name of the object, the name of the function message and the information to be sent.

Getters and Setters

   >>> The concept of getters and setters supports the concept of data hiding.

   >>> Because other objects should not directly manipulate data within another object, the getters and setters provide controlled access to an objects's data.

   >>> Getters and setters are sometimes called accessors methods or mutator methods.

>>>> The following information is all the user need to know to effectively use the methods:

    1. The name of the methods.
    2. The parameters passed to the method.
    3. The return type of the method.

Object's Attribute

   >>> In object oriented programming terminology, this data is called attributes. In our example, as shown in figure below, employee attributes could be Social Security number, date of birth, gender, phone number and so on.

   >>> The attributes contain the information  that differentiates between the various objects, in this case the employees.

   >>> Programming problem is analysed in terms of objects and nature of communication between them. When a program is executed, objects interact with each other by sending messages.

   >>> Behaviour of an object or Method.

          >>> The behaviour of an object is what the object can do.
          >>> An object's attributes.

   >>> In Procedural languages, the behaviour is defined by procedures, functions, subroutines. In object oriented programming terminology, these behaviours are contained in methods, and you invoke a method by sending a message to it.

   >>> In our employee example, consider that one of the behaviours required of an employee object is to set and return the values of the various attributes. Thus, each attribute would have corresponding methods, such as setGender() and gerGender().

   >>> In this case, when another object needs this information, it can send a message to an employee object and ask it what its gender is,


   >>> In Program the data is freely moving around the system and due to which there are chances of problem in system. So oop programs overcome this problem.

    >>> OOP concepts says it think about data and bind that data and methods those are manipulating that data into one entity known as object and the utilize that object into system.

   >>> Objects are the physical and conceptual things we find in the universe around us.
Hardware, software, documents, human beings and even concepts are all examples of objects.

   >>> Objects are the basic run - time entities in an object - oriented system. A Particular instance of a class.

   >>> We can create n number of object with one Class.

   >>> Class represent template for an object.

   >>> Object represents real world entity into a program. For example an employee that is real world entity we can make an object of it and then utilize it in a program with its behaviours and actions.

Figure :- oval shows a real world employee and middle square shows a class of an
employee which is created from a real world problem and Emp1, Emp2, Emp3......
                and Empn are all objects which are created from an employee class.

   >>> Object is a variable of user defined type.

   >>> The data stored within an object represents the state of the object.

   >>> The class of dog defines all possible dogs by listing the characteristics that they can have: the object kukki is one particular dog, with particular versions of the characteristics. 

   >>> A dog has fur; kukki has brown and white fur. In programmer jargon, the object kukki is an instance of the dog class. The set of values of the attributes of a particular object is called its state.

   >>> Objects are thought of as having state.

   >>> The state of an object is the condition of the object, or a set of circumstances describing the object.

   >>> it is not uncommon to hear people talk about the a" state information" associated with a particular object. For example, the state of a bank account object would include the current balance, the state of a clock object would be the current time, the state of an electric light bulb would be "on" or "off".


   >>> A class is a collection of objects of similar type. Once a class is defined, any number of objects can be created which belong to that class.

   >>> It actually contains data and there behaviour / methods in it and for utilization of it we need to create an object of that particular class.

   >>> A collection of data and code to handle that data.

   >>> Class is a user defined type / abstract data type.

   >>> A class is a pattern, template, or blueprint for  a category of structurally identical items. The items crated using the class are called instances.

   >>> A class is a set of objects that share a common structure and a common behaviour.

   >>>  Each class diagrams is broken up into two separate sections (besides the name itself). The first section contains the data (attributes), and the second section contains the behaviours (methods).

   >>> For example, the class Dog would consist of traits shared by all dogs, for example breed,fur color, and the ability to bark.

   >>> Classes provide modularity and structure in an object - oriented computer program.

   >>> In above figure, the employee class diagram's attributes section contains SocialSecurityNumber, Gender and DateOfBirthd, whereas the method section contains the methods that operate on these attributes.

   >>> A class should typically be recognizable to a non - programmer familiar with the problem domain, meaning that the characteristics of the class should make sense in context. Also, the code for a class should be relatively self - contained. Collectively, the properties and methods defined by a class are called members.

Friday, December 11, 2015

Concepts Of OOP:

   >>> In OOPS, we try to model real - world objects. But, What are real - world objects? Most real - world objects have internal parts and interfaces that enable us to operate them. These interface perfectly manipulate the internal parts of the objects. They also have the exclusive rights to do so.

             >>> Let us understand this concept with the help of example. Take the case of a simple LCD projector (a real world object). It has a fan lamp. however, the operation of these switches is necessarily governed by rules. If the lamp is switched on, the fan should automatically switch itself on. Otherwise, the LCD projector will get damaged. For the same reason, the lamp should automatically get switched off if the fan is switched off. In order to cater to these conditions, the switches are suitable linked with each other. The interface to the LCD projector is perfect. Further, this interface has the exclusive rights to operate the lamp and fan.

   >>> This, in fact, is a common characteristic of all real - world objects. if a perfect interface is required to work on an object, it will also have exclusive rights to do so.

Some Important Features Of Object Oriented Programming

 >>> Some Important Features Of Object Oriented Programming are as Follows :-

   >>> Emphasis on data rather than procedure.

   >>> Programs are divided into objects.

   >>> Data is hidden and cannot be accessed by external functions.

   >>> Object can communicate with each other through functions.

   >>> New data and function can be easily added whenever necessary.

   >>> Follows bottom - up approach. 

Why Object Oriented Approach?

   >>> A major factor in the invention of Object - Oriented approach is to remove some of the flaws encountered with the procedural approach.

   >>> In OOP, data is treated as a critical element and does not allow it to flow freely.

   >>> It bounds data closely to the functions that operate on it and protects it from accidental modification from outside functions.

   >>> OOP allows decomposition of a problem into a number of entities called objects and the builds data and functions around these objects.

   >>> A major advantage of OOP is code re - usability.

Object Oriented

  >>> Classes are symbolic representations of objects; they describe the properties, fields, methods, and events that make up objects in the same way that blueprints describe the items that make up a building.

   >>> Just as a blueprint can be used to create multiple buildings, a single class can be used to create as many objects as necessary.

   >>> Just as a blueprint defines which parts of a building are accessible to people who use the building, so too can classes control user access to object items through encapsulation. 

Standard Library

   >>> The 1998 C++ standard consists of two parts: the core language and the C++ standard library; the latter includes most of the standard template library and a slightly modified version of the C standard library.

   >>> All C++ compilers come with a standard library of functions that perform most commonly needed tasks.

   >>> The C++ standard library incorporates the C standard library with some small modification to make it work better with the C++  language. thus, all of the standard C functions are available for use in C++ programs.

   >>> The C++ standard library can be divide into: the standard functions library and the class library.

   >>> Another large part of the C++ library is based on the Standard Template Library (STL).

   >>> This Provides such useful tools as containers (for example vectors and lists), iterators (generalized pointers) to provide these containers with array - like access and algorithms to perform operation such as searching and sorting.  

   >>> C++ Provides sixty - nine standard headers, of which nineteen are deprecated.

   >>> The standard does not refer to it as "STL", as it is merely a part of the standard library, but many people still use that term to distinguish it from the rest of the library.

   >>> The Standard Template Library (STL) is a general - purpose C++ library of algorithms and data structures, originated by Alexander Stepanov and Meng Lee. The STL,based on a concept known as generic programming, is part of the standard ANSI C++ library. The STL is implemented by means of the C++ template mechanism, hence its name. While some aspects of the library are very complex, it can often be structures and algorithms it contains.

C++ Is Middle level Programming language

 >>> What is high - level programming language and low - level programming language?

      >>>  A high - level programming language is a programming language that, in comparison to low - level programming languages, may be more abstract easier to use, or more portable across platforms, such languages often abstract away CPU operation such as memory access models and management of scope.

     >>> Rather, " High - level language" refers to the higher level of abstraction from machine language. Rather than dealing with registers, memory addresses and call stacks, high - level languages deal with variables, arrays and complex arithmetic or boolean expressions.

     >>> An assembly language allows the programmer maximum control over the computer system. The programmer can directly interface with and control the computer's hardware and operation system.

    >>> But it's hard to learn because they are highly symbolic and the programmer must take care of all the details of the program, debugging and maintaining also difficult.

    >>> Example of the high - level languages are Cobol, visual basic and Java.

    >>> C++ is middle level language contains many of the low - level capabilities of an assembly language. It's possible through C++ to attain almost as much control over the computer as you can achieve with and assembly language.

What is the Requirement of Standard?

     >>> Companies view standards not only as key to impacting product development, quality or environmental compliance, but also as an imperative in competing successfully in the global marketplace. The effective use of strategic standardization in achieving competitiveness, quality product certification and conformity assessment became critical issues facing the business and the standardization community in the decade.

What is a standard?

    >>> A definition or format that has been approved by a recognized standards organization.

    >>> Standards exits for programming languages, operating systems, data formats, communication protocols, and electrical interfaces.

    >>> From a user's standpoint, standards are extremely important in the computer industry because they allow the combination of products from different manufactures to create a customized system. without standards, only hardware and software from the same company could be used together, In addition, standard user interfaces can make it much easier to learn how to use new applications.

ANSI (American National Standards Institute).

>>> Acronym For The American National Standards Institute.

        >>> Founded in 1918, ANSI is a voluntary organization composed of over 1300 members (including all the large computer companies) that creates standards for the computer industry.

        >>> For Example, ANSI C is a version of the C language that has been approved by the ANSI committee.

        >>> To a large degree, all ANSI C compilers, regardless of which company produces then, should behave similarly.

        >>> In addition to programming languages, ANSI sets standards for wide range of technical areas, from electrical specification to communications protocols. For Example,  FDDI, the main set of protocols for sending data over fiber optic cables, is an ANSI standard.

       >>> This Institute oversees the creation, promulgation and use of thousands of norms and guidelines that directly impact businesses in nearly every sector: from acoustical devices to construction equipment, from dairy and livestock production to energy distribution, and many more. ANSI is also actively engaged in accrediting programs that assess conformance to standards - including globally - recognized cross -sector programs such as the ISO 9000 (quality) and ISO 14000 (environmental) management systems.

Features Of C++

C++ is designed to be as compatible with C as possible, therefore providing a smooth transition from C.

Object - Oriented - Programming

               >>>  The possibility to orientate programming to objects allows the programmer to design application from a point of view more like a communication between objects rather code in a more logical and productive way.


               >>> You can practically compile the same C++ code in almost any type of computer and operating system without making any changes. C++ is the most used and ported programming languages in the world.


              >>> Code written in C++ is very short in comparison with other languages, since the use of special characters is preferred to key words, saving some effort to the programmer (and prolonging the life of our keyboards!).

Modular Programming
              >>> An application's body in C++ can be made up of several source code files that are compiled separate and then linked together. Saving time since it is not necessary to recompile the complete application when making a single change but only the file that contains it, in addition, this characteristic allows to link C++ code with code produced in other languages, such as assembler or C.

C Compatibility 

             >>>  C++ is backwards compatibility with the C language. Any code written in C can easily be included in a C++ Program without hardly making any change.


             >>> The resulting code from a C++ compilation is very efficient, due indeed to its duality as high - level and low - level language and to the reduced size of the language itself.

Cross - Platform Environments

           >>> In other words, C++ code can be used to develop programs for vast operating systems including MS - DOS, windows, Macintosh, UNIX, to name just a few.

The Name "C++"

>>> This name is credited to Rick Mascitti (mid - 19830) and was first used in December 1983.

>>> Earlier, During the research period, the developing language had been referred to as " new C", then "C with Classes".

>>> In computer science C++ is still referred to as a superstructure of C. The final name Stems From C's "++" operator (which Increments the value of a variable) and a common naming convention of using "+" to indicate an enhanced computer program.

What Is C++

>>> C++ Pronounced " See Plus Plus" is a general - purpose, middle-level programming language with low-level facilities.

>>> C++ is a general - purpose, platform - neutral programming language that supports object - oriented programming and other useful programming paradigms.

>>> C++ doesn't have versions. 

During 1983 - 1985, C++ Was Written By Bjarne Stroustrup As Bell Labs.

C++ is an extension of c. Before 1983, Bjarne Stroustrup added some Features to C and he called "C with classes". He had combined the SIMULA's classes and object - oriented features with the power and efficiency of c. The term C++ was first used in 1983.

(Bjarne Stoustrup)

After first release, C++ was developer significantly. In particular, "ARM C++" added exceptions and templates, and ISO C++ added RTTI, namespace and a standard library.

C++ was designed for the UNIX system environment Programmers could improve the quality of code they produced and reusable code was easier to write with C++.

Enhancements started with the addition of classes, followed by among other features,virtual function, operator overloading, multiple inheritance, templates, and exception handling.

Compared to the C language C++ introduced extra casts, new/delete, bool, reference types, in-line functions, default arguments, function overloading, namespaces classes (including all class - related features such as inheritance, member functions, virtual function , abstract classes, and constructors) operator overloading, templates the :: operator, exception handling, and runtime type identification.