CPP Notes

C
DSA
Software Engineering
Software Architecture
Operating System
Big Data
Data Mining and Warehousing
TOC
Ada
CPP
DBMS

All Topics (10)

  • 1. Introduction to Cpp
  • 2. Why Cpp is Called Cpp
  • 3. Why Cpp is Used
  • 4. Difference Between C and Cpp (Syntax)
  • 5. What is Cpp.
  • 6. What are private and public in Cpp?
  • 7. General Syntax of Declaring a Class
  • 8. Cpp Code
  • 9. Program.
  • 10. What is Relation between OOP and Cpp

1. Introduction to Cpp

Developer

  • C++ was developed by Bjarne Stroustrup.

Company

  • Developed at AT&T Bell Laboratories.

Launching Year

  • Development started in 1979.

  • First released in 1983.

2. Why Cpp is Called Cpp

  • The original name of C++ was C with Classes.

  • Later the name was changed to C++.

Meaning of C++

  • In C language, ++ is an increment operator which means adding one.

  • Therefore C++ means an improved or extended version of C language.

3. Why Cpp is Used

C++ supports all the basic features of C language and also provides additional features.

Features from C Language

C++ supports all primary concepts of C such as:

  • Data Types

  • Operators

  • Control Statements

  • Functions

Extra Features in C++

C++ also supports Object Oriented Programming (OOP) concepts, such as:

  • Class

  • Object

  • Encapsulation

  • Inheritance

  • Polymorphism

  • Abstraction

Because of these features, C++ is called an Object Oriented Programming Language.

4. Difference Between C and Cpp (Syntax)

C Language C++ Language
Most common header file is stdio.h Most common header file is iostream
Provides functions printf() and scanf() Provides objects cout, cin, cerr, clog
printf() is used for console output cout is used for console output
scanf() is used for console input cin is used for console input

 

5. What is Cpp.

C++ is a high level, object oriented programming language.
It is a case sensitive language.

Example: A and a are different.

2. Program

A program is a set of instructions given to a computer to perform a specific task.

3. Character

A character is the smallest unit of a program used to form tokens.

Examples:
Letters (A–Z), Numbers (0–9), Symbols (+ - * / #)

4. #

# is a preprocessor directive.

5. #include

Used to include header files in a program.

Example:

#include <iostream>
 

6. < >

Called angular brackets.

7. Header File

A file that contains functions and libraries used in programs.

Example:

  • <iostream> → Input/Output

  • <conio.h> → Console input/output

.h = Header file extension

8. Stream

Stream means flow of data (bytes).

9. main() Function

The starting point of program execution.

Example:

int main()
 

10. { }

Curly braces

  • { → Start of block

  • } → End of block

11. ;

Semicolon → End of statement

12. cout

Used to display output on the screen.

Example:

cout << "Hello";
 

13. cin

Used to take input from keyboard.

Example:

cin >> a;
 

14. <<

Left shift operator
Used with cout for output.

15. >>

Right shift operator
Used with cin for input.

16. " "

Double quotes used for string/message.

Example:

"Hello"
 

17. getch()

Used to hold the screen.

18. clrscr()

Used to clear the screen.

19. Simple C++ Program

 
#include <iostream>
using namespace std;

int main()
{
int a,b,c;

cout<<"Enter two numbers:";
cin>>a>>b;

c=a+b;

cout<<"Sum is "<<c;

return 0;
}
Page 1 of 2