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

Cpp_Notes

This document provides an overview of C++, a general-purpose programming language that supports both procedural and object-oriented programming. It covers key concepts such as program structure, variables, data types, operators, conditional statements, loops, functions, arrays, strings, object-oriented programming principles, inheritance, file handling, and the Standard Template Library (STL). Additionally, it includes code examples to illustrate each concept.

Uploaded by

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

Cpp_Notes

This document provides an overview of C++, a general-purpose programming language that supports both procedural and object-oriented programming. It covers key concepts such as program structure, variables, data types, operators, conditional statements, loops, functions, arrays, strings, object-oriented programming principles, inheritance, file handling, and the Standard Template Library (STL). Additionally, it includes code examples to illustrate each concept.

Uploaded by

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

C++ Notes

1. Introduction to C++:

- C++ is a general-purpose programming language.

- Supports both procedural and object-oriented programming.

- Extension of the C language.

2. Structure of a C++ Program:

#include<iostream>

using namespace std;

int main() {

cout << "Hello, World!";

return 0;

3. Variables and Data Types:

- Common types: int, float, double, char, bool

int a = 5;

float b = 3.14;

char c = 'A';

bool isTrue = true;

4. Operators:

- Arithmetic: +, -, *, /, %

- Relational: ==, !=, >, <, >=, <=


- Logical: &&, ||, !

5. Conditional Statements:

if (condition) {

// code

} else if (condition) {

// code

} else {

// code

6. Loops:

for (int i = 0; i < 5; i++) {

cout << i << endl;

while (condition) {

// code

do {

// code

} while (condition);

7. Functions:

int add(int a, int b) {

return a + b;
}

8. Arrays:

int arr[5] = {1, 2, 3, 4, 5};

cout << arr[0];

9. Strings:

string name = "John";

cout << name.length();

10. Object-Oriented Programming:

- Class and Object

class Person {

public:

string name;

int age;

void introduce() {

cout << "Name: " << name << ", Age: " << age;

};

11. Constructors and Destructors:

class MyClass {

public:

MyClass() { cout << "Constructor called!"; }

~MyClass() { cout << "Destructor called!"; }

};
12. Inheritance:

class Animal {

public:

void sound() { cout << "Animal sound"; }

};

class Dog : public Animal {

public:

void bark() { cout << "Woof!"; }

};

13. File Handling:

#include<fstream>

ofstream file("example.txt");

file << "Hello";

file.close();

14. STL (Standard Template Library):

- Useful containers: vector, list, map

#include<vector>

vector<int> v = {1, 2, 3};

v.push_back(4);

15. Useful Functions and Keywords:

- sizeof(), return, break, continue, new, delete

You might also like