Partial preview of the text
Download C++programing CP computer and more Study notes Computer science in PDF only on Docsity!
1.Introduction About C++ What is Programming? A Programming language is used to direct a computer to accomplish a specific set of Steps which results to a desired output. A computer can understand only its own native code i.e. the machine code. Machine code is the lowest level of programming language in which we can write Program. The very first program was written in pure binary notation where both, data and Instructions, had to be encoded in strings of 1s and 0s. A low-level language corresponds closely to the machine code, so that, a single low-level language instruction translates to a single machine language instruction, The middle level and high-level programming language translate an instruction into a Series of machine-language instruction. The levels can be categorized as o Binary Programming o Assembly Programming o Procedure Oriented Programming o Structured Programming Language o Object Oriented Programming o Visual Programming The assembly language made programming easier than machine language. High Level languages use word and verbs to command the computer, Compiler languages are the high-level languages which are equivalent of assembly Language. What is Object Oriented Programming [OOPs]? Before OOP, the computer programming was organized around logic and actions. The OOP is organized around objects and data. In OOP, right from human being to buildings and floors and animals and machines, To Buttons, scroll bars, windows, toolbars everything is object. Object is a thing whose properties can be described, manipulated and managed. Object Combines data and function that Operates data into a single unit known as object. All objects in nature have their own identity and its behaviour (What an object does) And these two characteristics help us to recognize them. * In most of the software, the two things data and process are separated in programming. In OOP, these two are linked. This linking is called enc Data + Process/ Method = Object (Private) (Public) * That means the data and its function are encapsulated into a single entity, APSula BASIC CONCEPTS OF OOP; It is necessary to understand some of the concepts used extensively in object-orien programming. These includes: Objects and Classes Data abstraction and Encapsulation Inheritance Polymorphism Dynamic binding Message Passing OBJECT and CLASSES: Class is a user defined data type. Class variable is object. Class is a collection of objects of similar type. Class members are variables and functions. Objects are run-time entities in Object Oriented system. Objects are service providers. Each object is an independent entity with its own lifetime. Objects contain data, and code to manipulate that data. Object is a software entity that combines state and behaviour. DATA ABSTRACTION AND ENCAPSULATION: * Encapsulation refers to Wrapping up of data and functions into a single unit (class) The insulation of the data from direct access by the program is called data hidir Or information hiding. Abstraction refers to the act of representing essential features without including explanations. Since classes use the concept of data abstraction, they are known as Abstract D, Types (ADT). INHERITANCE: eae ene NT ET ETT Characteristics of C++? * Itis a better C. * Tt is a general-purpose language. * It supports object-oriented programming, * It supports generic programming where we can use data type as argument. * Tt is bias towards system programming. * Tt supports data abstraction. * C++ supports both type of overloading i.e. method overloading and operator overloading. * C++ allows pointer arithmetic. The access controls available in C++ are public, protected, private, and friend, * C++ isa statically typed language that requires all variables declared with a specific type. History of C++ * The earlier version of C++ language, known as “C with classes” have been in y since 1980. . The first use of C++ outside a research organization started in July 1983. | Rick Mascitti coined the term C++ in the summer of 1983 as an extension of € BCPL’s // comment conversion is reintroduced in C++. Other main source of inspiration for CH was Simula67. The class concept in C++ was borrowed from Simula67. The facility of overloading operators and the freedom to place a declaration wherever a Statement can occur of C++ resembles Algol68. + The exception-handling mechanism of C++ was inspired partly by Ada, Clu, ang ML. Some of the important milestones on the road of Object Orientation are + 1968 Simula67 — the first object-oriented language + 1970 Graphical User Interface (GUI) Developed using Object Orientation. David Parma’s seminar paper on “Information hiding” + 1972 + 1980 First version of Smalltalk (Alan Kay) + 1983 First version of C++ (Bjom Stroustrup) + 1988 First version of Eiffel (Bertrand Meyer) Difference between Sr | Key | Cc CH ] | | No. | a 1 ntroduction | C was developed by Dennis CH was developed by Bjarne Ritchie in around 1969 at Strostrup in 1979 oe ___| AT&T Bell Labs. ae 2 Language As mention before C is C++ supports both procedural wa | Type procedural programming. object-oriented programming _ paradigms. 3 OOPs As C does not support the OOPs | C++ has support for Feature concept so it has no support for Support polymorphism, encapsulation and polymorphism, encapsulation inheritance as it being an and inheritance objectoriented programming language. Data security | As C does not support In case of C++, encapsulation hides encapsulation so data behaves as the data to ensure that data a free entity and can be structures and operators intended. manipulated by outside code, 5 Storage Uses malloc and calloc Uses new and delete Allocation TOKENS: Tokens are smallest individual units in a program. . Tokens in C++ are Keywords Identifiers Constants Operators A C++ program consists of tokens, white spaces, and syntaxes of the language. KEYWORDS: Many of the keywords in C and C++ are common, Keyword implements the language features. Keyword are the identifiers reserved by language. They cannot be used as variable names or other user-defined program elements. Following is the list of C++ keywords-