0% found this document useful (0 votes)
4 views

LECTURE-1

C++ is a middle-level programming language developed by Bjarne Stroustrup that supports object-oriented programming and offers low-level memory management. It differs from C in several ways, including support for classes, function overloading, and exception handling, making it more secure and versatile. The document also provides a basic example of a C++ program and explains its components.

Uploaded by

Shub P
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

LECTURE-1

C++ is a middle-level programming language developed by Bjarne Stroustrup that supports object-oriented programming and offers low-level memory management. It differs from C in several ways, including support for classes, function overloading, and exception handling, making it more secure and versatile. The document also provides a basic example of a C++ program and explains its components.

Uploaded by

Shub P
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 4

LECTURE 1

BASIC INTODUCTION OF C++

• C++ is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs. C++ runs on a
variety of platforms, such as Windows, Mac OS, and the various versions of UNIX. This C++ tutorial adopts a simple and
practical approach to describe the concepts of C++ for beginners to advanded software engineers.

• C++ is very close to hardware, so you get a chance to work at a low level which gives you lot of control in terms of memory
management, better performance and finally a robust software development.

• C++ programming gives you a clear understanding about Object Oriented Programming. You will understand low level
implementation of polymorphism when you will implement virtual tables and virtual table pointers, or dynamic type
identification.

• C++ is the most widely used programming languages in application and system programming. So you can choose your area
of interest of software development.
• C++ really teaches you the difference between compiler, linker and loader, different data types, storage classes, variable
types their scopes etc
C vs. C++

• The following are the differences between C and C++:


• Definition
C is a structural programming language, and it does not support classes and objects, while C++ is an object-oriented programming
language that supports the concept of classes and objects.
• Type of programming language
C supports the structural programming language where the code is checked line by line, while C++ is an object-oriented
programming language that supports the concept of classes and objects.
• Developer of the language
Dennis Ritchie developed C language at Bell Laboratories while Bjarne Stroustrup developed the C++ language at Bell Labs circa
1980.
• Subset
C++ is a superset of C programming language. C++ can run 99% of C code but C language cannot run C++ code.
• Type of approach
C follows the top-down approach, while C++ follows the bottom-up approach. The top-down approach breaks the main modules
into tasks; these tasks are broken into sub-tasks, and so on. The bottom-down approach develops the lower level modules first and
then the next level modules.
• Security
In C, the data can be easily manipulated by the outsiders as it does not support the encapsulation and information hiding while C+
+ is a very secure language, i.e., no outsiders can manipulate its data as it supports both encapsulation and data hiding. In C
language, functions and data are the free entities, and in C++ language, all the functions and data are encapsulated in the form of
objects.
• Function Overloading
Function overloading is a feature that allows you to have more than one function with the same name but varies in the
parameters. C does not support the function overloading, while C++ supports the function overloading.
continue…
• Reference variables
C does not support the reference variables, while C++ supports the reference variables.
• Keywords
C contains 32 keywords, and C++ supports 52 keywords.
• Namespace feature
A namespace is a feature that groups the entities like classes, objects, and functions under some specific name. C does not
contain the namespace feature, while C++ supports the namespace feature that avoids the name collisions.
• Exception handling
C does not provide direct support to the exception handling; it needs to use functions that support exception handling. C+
+ provides direct support to exception handling by using a try-catch block.
• Input/Output functions
In C, scanf and printf functions are used for input and output operations, respectively, while in C++, cin and cout are used
for input and output operations, respectively.
• Memory allocation and de-allocation
C supports calloc() and malloc() functions for the memory allocation, and free() function for the memory de-allocation. C++
supports a new operator for the memory allocation and delete operator for the memory de-allocation.
• Inheritance
Inheritance is a feature that allows the child class to reuse the properties of the parent class. C language does not support
the inheritance while C++ supports the inheritance.
• Header file
C program uses <stdio.h> header file while C++ program uses <iostream.h> header file.
C++ Program
• Before starting the abcd of C++ language, you need to learn how to write, compile and run the first C++ program.
• To write the first C++ program, open the C++ console and write the following code:
• #include <iostream.h>
• #include<conio.h>
• void main() {
• clrscr();
• cout << "Welcome to C++ Programming.";
• getch();
• }
• #include<iostream.h> includes the standard input output library functions. It provides cin and cout methods for reading
from input and writing to output respectively.
• #include <conio.h> includes the console input output library functions. The getch() function is defined in conio.h file.
• void main() The main() function is the entry point of every program in C++ language. The void keyword specifies that it
returns no value.
• cout << "Welcome to C++ Programming." is used to print the data "Welcome to C++ Programming." on the console.
• getch() The getch() function asks for a single character. Until you press any key, it blocks the screen.

You might also like