Introduction to C++.pdf
Document Details
Uploaded by FineProtactinium
Tags
Full Transcript
Introduction to C++ Course Code: CC 113 (B) Course Title: Introduction to Programming (C++) Prepared by: Alvin Herrera, Instructor 1 C++ History C++ programming language was developed in 1980 by Bjarne Stroustrup at bell laboratories of AT&T (American Telephone & Telegraph), lo...
Introduction to C++ Course Code: CC 113 (B) Course Title: Introduction to Programming (C++) Prepared by: Alvin Herrera, Instructor 1 C++ History C++ programming language was developed in 1980 by Bjarne Stroustrup at bell laboratories of AT&T (American Telephone & Telegraph), located in U.S.A. Bjarne Stroustrup is known as the founder of C++ language. It was develop for adding a feature of OOP (Object Oriented Programming) in C without significantly changing the C component. C++ programming is "relative" (called a superset) of C, it means any valid C program is also a valid C++ program Bjarne Stroustrup Founder of C++ C++ History The C++ programming language has a history going back to 1979, when Bjarne Stroustrup was doing work for his Ph.D. thesis. One of the languages Stroustrup had the opportunity to work with was a language called Simula, which as the name implies is a language primarily designed for simulations. The Simula 67 language - which was the variant that Stroustrup worked with - is regarded as the first language to support the object-oriented programming paradigm. Stroustrup found that this paradigm was very useful for software development, however the Simula language was far too slow for practical use. C++ History Shortly thereafter, he began work on "C with Classes", which as the name implies was meant to be a superset of the C language. His goal was to add object-oriented programming into the C language, which was and still is a language well-respected for its portability without sacrificing speed or low-level functionality. His language included classes, basic inheritance, inlining, default function arguments, and strong type checking in addition to all the features of the C language. C++ History In 1983, the name of the language was changed from C with Classes to C++. The ++ operator in the C language is an operator for incrementing a variable, which gives some insight into how Stroustrup regarded the language. Many new features were added around this time, the most notable of which are virtual functions, function overloading, references with the & symbol, the const keyword, and single-line comments using two forward slashes (which is a feature taken from the language BCPL). C++ Features 1. Simple C++ is a simple language because it provides a structured approach (to break the problem into parts), a rich set of library functions, data types, etc. 1. Structured programming language C++ is a structured programming language. In this we can divide the program into several parts using functions. C++ Features 3. Rich Library C++ provides a lot of inbuilt functions that make the development fast. Following are the libraries used in C++ programming are: , , , 4. Reusability With the use of inheritance of functions programs written in C++ can be reused in any other program of C++. You can save program parts into library files and invoke them in your next programming projects simply by including the library files. New programs can be developed in lesser time as the existing code can be reused. It is also possible to define several functions with same name that perform different task. For Example: abs () is used to calculate the absolute value of integer, float and long integer. C++ Features 5. Errors are easily detected It is easier to maintain a C++ programs as errors can be easily located and rectified. It also provides a feature called exception handling to support error handling in your program. 6. Modelling real-world problems The programs written in C++ are well suited for real-world modeling problems as close as possible to the user perspective. 7. Clarity The keywords and library functions used in C++ resemble common English words. What is an Integrated Development Environment - IDE? An integrated development environment (IDE) is a software application that helps programmers develop software code efficiently. It increases developer productivity by combining capabilities such as software editing, building, testing, and packaging in an easy-to-use application. Just as writers use text editors and accountants use spreadsheets, software developers use IDEs to make their job easier. Why Integrated Development Environment - IDEs important? You can use any text editor to write code. However, most integrated development environments (IDEs) include functionality that goes beyond text editing. They provide a central interface for common developer tools, making the software development process much more efficient. Developers can start programming new applications quickly instead of manually integrating and configuring different software. They also don't have to learn about all the tools and can instead focus on just one application. Why Integrated Development Environment - IDEs important? The following are some reasons why developers use IDEs: Code editing automation Programming languages have rules for how statements must be structured. Because an IDE knows these rules, it contains many intelligent features for automatically writing or editing the source code. Syntax highlighting An IDE can format the written text by automatically making some words bold or italic, or by using different font colors. These visual cues make the source code more readable and give instant feedback about accidental syntax errors. Why Integrated Development Environment - IDEs important? The following are some reasons why developers use IDEs: Intelligent code completion Various search terms show up when you start typing words in a search engine. Similarly, an IDE can make suggestions to complete a code statement when the developer begins typing. Compilation An IDE compiles or converts the code into a simplified language that the operating system can understand. Some programming languages implement just-in-time compiling, in which the IDE converts human-readable code into machine code from within the application. Why Integrated Development Environment - IDEs important? Testing The IDE allows developers to automate unit tests locally before the software is integrated with other developers' code and more complex integration tests are run. Debugging Debugging is the process of fixing any errors or bugs that testing reveals. One of the biggest values of an IDE for debugging purposes is that you can step through the code, line by line, as it runs and inspect code behavior. IDEs also integrate several debugging tools that highlight bugs caused by human error in real time, even as the developer is typing. IDE we are going to use Visual Studio 2012 is an integrated development environment (IDE) developed by Microsoft, released in 2012. It is a major update to the Visual Studio family of products, designed to support a wide range of programming languages, including C++, C#, F#, Visual Basic.NET, and JavaScript. C++ Hello World program Probably the best way to start learning a programming language is by writing a program. Therefore, here is our first program: