Presentation is loading. Please wait.

Presentation is loading. Please wait.

C++ Programming Basic Learning Prepared By The Smartpath Information systems www.thesmartpath.in.

Similar presentations


Presentation on theme: "C++ Programming Basic Learning Prepared By The Smartpath Information systems www.thesmartpath.in."— Presentation transcript:

1 C++ Programming Basic Learning Prepared By The Smartpath Information systems www.thesmartpath.in

2 Index 1.About C++ Programming Language 2.Basic Concepts of OOPs 3.Basic Concepts of OOPs(continue….) 4.Basic Concepts of OOPs(continue….) 5.Basic Concepts of OOPs(continue….) 6.Benefits 7.Languages with Object Oriented Features 8.C++ Programming Environment 9.C++ Program Structure 10.C++ Program Structure (Explanation) 11.Creating Class and Objects 12.Explanation

3 Index 14. C++ Program Syntax 15. Keywords 16. Data Types 17. Operators in C++ 18. Operators in C++ (continue….) 19. Variables 20. Working With Classes 21. Feature of OOP - Inheritance 22. Types of Inheritance 23. Polymorphism - Operator Overloading 24. Operators that cannot be overloaded 25. OOPs Applications

4 About C++ programming language C++ is an object-oriented programming language developed by Bjarne Stroustrup at AT&T Bell Lab in the year 1980. Initially it was named “C with classes” but later in 1983 the name changed to C++. It is an extension of C with major addition of classes. It supports concepts of Object Oriented Programming known as OOP concepts C++ can be said as superset of C. It provides bottom-up and object oriented design.

5 Basic concepts of object oriented programming Objects Object is an entity in program. They are also called class variables. An object represents real world things such as person, student, etc Objects contain data and methods in it. When object is created in a program memory is allotted to a program. Class Class is a user-defined data type which holds data and program code. It is collection of objects of similar type.

6 Concepts of object oriented programming Encapsulation The wrapping up of data and functions in a class is known as encapsulation. The functions inside class can use the data within it. It is not accessible outside world directly only function who is member of class or friend function can access data. Data Abstraction Abstraction is hiding details of a process and presenting essential features to the user. By creating a class and putting data and methods in it. We use objects to access.

7 Concepts of object oriented programming Inheritance The feature of inheritance provides reusability of class. This is a process through Which a class acquires the properties of another class. The class which is created By inheritance is called derived class, and class whose features are inherited is Called base class Polymorphism It is the feature that gives ability to take different forms. To behave differently in different forms. It is done through operator overloading. An operator has one or more behavior. With same name it acts differently

8 Concepts of object oriented programming Dynamic Binding binding is done as compiler does not know what are functions in a program. It gets to know when binding or linking of code and function is done either at run time or compile time. Run time binding is called as dynamic binding or early binding. It is linking of code and function at the run time. Also called late binding. In early binding or compile time binding function and code are linked when file is compiled Message passing Just as people communicate with each other. Objects also communicate with each other through message passing. They send and receive information with] each other. When object gets message it invokes a procedure in it and generate results of the procedure call.

9 Benefits Benefits of OOP  object oriented systems can easily be upgraded from small to large systems  software complexity can be easily managed  Through Inheritance classes once created can be used again as required  Through abstraction and data hiding. Data is secure.

10 languages with object oriented features 1. C++ 2. JAVA 3. C# 4. Falcon 5. Delphi 6. Objective C 7. Python 8. PHP5 9. Perl

11 C++ programming Environment C++ Programming Environment consists of Text Editor and C++ compiler (1) Text Editor - Programs are typed in Text Editor. By default a new file Noname.cpp is opened. Type your programs here, save it, compile and run. (2) Compiler – Compiler is a System software that is installed on computer to compile and run programs. Most widely Turbo C compiler is used

12 C++ program Structure A C++ program consists of the following 1. Class 2. Methods 3. Object 4. Instance Variables For Example creating a class #include int main( ) { statements; getch(); return 0; }

13 C++ program Structure Explained 1. #include - This statement adds the necessary header file iostream.h to the program. It contains methods for input and output in a program 2 int main() – The program execution starts with main method. 3. Type the statements inside main( ) method.. 4. getch() – marks the end of program and returns to programming window 5. return 0- In C++ main() method is of int type, it is not necessary to return a value always so we take return 0; statement.

14 Creating Class and objects in C++ Example of class and object #include Class sample // class named Sample { public: int a; // instance variable void get() // member method }; Int main( ) { sample S; // method is called using object S S.get(); }

15 Explanation 1. Class is created using class ‘keyword’ 2. Class has name Sample it has instance variable in which data is stored 3. It has member method called get(). It can access the data in it. 4. main() method is defined. 5. An Object of class is created in main() 6. method of class is called using object of class

16 C++ program Syntax 1.In Each Program header file iostream.h is included in the beginning 2. put semicolon at the end of each statement 3. When using classes create class and put semicolon at the closing bracket 4. method are called member methods and variables are called data member 5.The main method is of type int. ie.. Int main() is used in programs 6.Getch() is placed before return 0; 7.Return 0; statement is necessary because main has return type int. 8. Comments are given after two slashes as // comments 9. comments are not executed they are used to enhance readability of program

17 Key Concepts

18 DataTypes

19 Operators in C++ 1. Arithmetic operators 2. Relational operators addition + Equals == subtraction - Not Equal != Multiplication * Greater than > Division / Greater than equal to >= Modulus % Less than < Less than equal to <=

20 Operators in C++ 3. Logical operators logical AND && logical OR || logical NOT ! 4. Scope Resolution Operator - :: 5. Memory allocation operator - new 6. Memory release operator - delete 7. Line feed operator - endl 8. Field Width operator - setw()

21 Variables Variables in C++ is valid name in the memory where input given by user is stored and the result of program is stored. When a variable is declared in program, it occupies space in memory according to its size. Such as integer type takes 2 bytes of memory, char type takes 1 byte of memory Example : #include int main() { int a; float b; }

22 Working with Classes A class definition starts with the keyword class followed by the class name; and the class body, enclosed by a pair of curly braces. A class definition must be followed either by a semicolon or a list of declarations. The keyword public determines the access attributes of the members of the class that follow it. A public member can be accessed from outside the class anywhere within the scope of the class object. You can also specify the members of a class as private or protected. Private member cannot be accessed out side the class. Only the public member method of a class can access private data and method Protected – It determines the scope up to a single level of inheritance

23 Feature of OOPs - Inheritance Inheritance Inheritance is using the previously defined class as required Base Class – The Class which is used for deriving a new class and whose features are used by it, is called Base class. Derived Class- The newly formed class which contains features of base class and also contains features of its own

24 Types of Inheritance

25 Polymorphism – operator overloading Polymorphism It is achieved through operator overloading. With this we can create new definition of the operators by giving special meaning to them. Syntax: class name : : operator (arguments) { statements; } Example: void sample : : + operator() { x = +x; y = +y; }

26 Operators that cannot be overloaded 1. Class member access operators - ( dot., *) 2. Scope resolution operator - :: 3. Size operator - sizeof( ) 4. Conditional operator - ? :

27 Oops Applications 1. Real Time Systems 2. Simulation and Modeling 3. Object Oriented Databases 4. Hypertext, hypermedia 5. Decision Support Systems 6. Office Automation Systems 7. CAD / CAM Systems

28


Download ppt "C++ Programming Basic Learning Prepared By The Smartpath Information systems www.thesmartpath.in."

Similar presentations


Ads by Google