0% found this document useful (0 votes)
44 views7 pages

C++ Full Notes

This document provides comprehensive notes on C++ programming, covering its introduction, basic syntax, variables, data types, input/output, operators, conditional statements, loops, functions, arrays, strings, pointers, and object-oriented programming concepts such as classes, inheritance, and polymorphism. It also touches on file handling, advanced topics like STL and exception handling, and offers pro tips for practice. The notes emphasize the importance of logic, efficiency, and clean structure in C++ programming.

Uploaded by

kingsuvathikan
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)
44 views7 pages

C++ Full Notes

This document provides comprehensive notes on C++ programming, covering its introduction, basic syntax, variables, data types, input/output, operators, conditional statements, loops, functions, arrays, strings, pointers, and object-oriented programming concepts such as classes, inheritance, and polymorphism. It also touches on file handling, advanced topics like STL and exception handling, and offers pro tips for practice. The notes emphasize the importance of logic, efficiency, and clean structure in C++ programming.

Uploaded by

kingsuvathikan
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/ 7

C++ full code notes

suvathikan
1. Intro to C++

 Developed by Bjarne Stroustrup


 Extension of C with object-oriented features
 File extension: .cpp

Basic Template:

#include <iostream>

using namespace std;

int main() {

cout << "Hello World!";

return 0;

2. Variables & Data Types

int age = 13;

float price = 99.99;

char grade = 'A';

bool isSmart = true;

string name = "Suvathikan";

Rules: No space, no starting with numbers, no special symbols except _.

3. Input & Output

cin >> age; // Input


cout << age; // Output
4. Operators

 Arithmetic: + - * / %
 Assignment: = += -= *=
 Comparison: == != > < >= <=
 Logical: && || !

5. Conditional Statements
if (age > 18) {
cout << "Adult";
} else {
cout << "Kid";
}

Next code :

switch(choice) {

case 1: cout << "Start"; break;

case 2: cout << "Exit"; break;

default: cout << "Invalid";

6. Loops

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

cout << i;

int i = 0;

while (i < 5) {

cout << i;

i++;

}
do {

cout << i;

i++;

} while (i < 5);

⃣ Functions

cpp

int add(int a, int b) {

return a + b;

✅ Call it: add(5, 10);

⃣ Arrays

cpp

int marks[3] = {90, 80, 70};

cout << marks[0];

⃣ Strings

cpp

string name = "Suvathikan";

cout << name.length();

✅ Use <string> header.

✅ Pointers

cpp
int x = 10;

int* ptr = &x;

cout << *ptr; // Dereference = value

✅ Object-Oriented Programming (OOP)

➤ Class & Object

cpp

class Car {

public:

string brand;

void start() {

cout << "Vroom!";

};

Car c1;

c1.brand = "BMW";

c1.start();

➤ Constructor

cpp

Edit

class Student {
public:

Student() {

cout << "Constructor called!";

};

➤ Inheritance

cpp

class Animal {

public:

void speak() {

cout << "Sound";

};

class Dog : public Animal {};

Dog d;

d.speak();

➤ Polymorphism

cpp

Copy

Edit
class A {

public:

void show() { cout << "A"; }

};

class B : public A {

public:

void show() { cout << "B"; }

};

B b;

b.show(); // Output: B

✅ File Handling

cpp

Copy

Edit

#include <fstream>

ofstream myFile("data.txt");

myFile << "Hello!";

myFile.close();

✅ Advanced Stuff (Quick Glimpse)

 STL (Standard Template Library): vector, map, set


 Exception Handling: try { ... } catch(...) { ... }
 Namespaces
 Friend functions
 Virtual functions

#. Pro Tips:

Practice in CodeBlocks, Replit, or VS Code

Use #include for extra features like <vector>, <cmath>

C++ is all about logic, efficiency, and clean structure

You might also like