• Have Any Queries +919677781155
  • Call : 1800 889 0145
  • info@elysiumacademy.org
  • Have Any Queries +919677781155
  • Call : 1800 889 0145
  • info@elysiumacademy.org
Logo (2)
  • About Us
    • Academy Overview
    • Mission & Vision
    • Foot Steps
    • Our Pillars
    • Gallery
    • Testimonials
      • Video Testimonials
      • Reviews
    • Our Awards
  • Tesbo Courses
      Tesbo Courses PREMIUM
      • Full Stack JS Programmer Course
      • Full Stack Core Programmer
      • Full Stack Native Programmer
      • Data Analyst CourseOFFER
      • Testing Expert CourseOFFER
      • Mobile App Developer Course
      • IT Infra Manager
      • Cloud Architect Course
      • DevOps Engineer Course
      • Digital Marketing CourseOFFER
      Slash CoursesBUDGET
      • Core C & C++ Coures
      • Core Java & Concepts Course
      • Core Python & Concepts Course OFFER
      • Core UI Development Course
      • Microsoft Office Course
      • CompTIA – Hardware A+ Course
      Classic Courses BUDGET
      • Core C & C++ Coures
      • Core Java & Concepts Course
      • Core Python & Concepts Course OFFER
      • Core MSSQL Course
      • Digital Marketing Courses
      mega-menu
  • Professional Course
      Professional Courses
      Programming Training
      • Programming Course TOP
      • Advanced Java Course
      • Advanced Python Course
      Full Stack Training
      • MERN Stack Course
      • MEAN Stack Course
      Mobile App Training
      • Android Course
      • IOS CourseOFFER
      • Flutter & Dart Course
      • React Native CourseOFFER
      Cyber Security Training
      • Hacking Defender Course
      • Security+ Course
      • Security Analyst+ Course
      • Elynux Essentials Course
      Networking Tranining
      • CCNA - Cisco Solutions
      • CCNP - Switching , Routing
      • Hardware A+ & Network N+
      DB Management Training
      • MySQL & MSSQL Course
      • Oracle DB Management
      Software Testing
      • ISTQB Course TOP
      • Automation Testing TOP
      Data Science & Analyst
      • Python for Data Science-ML
      • DA- (R,Tableau & Power BI)
      Cloud Computing Training
      • Cloud Practioner Course
      • Cloud Solution Architect Course
      • DevOps Professional Course
      • Cloud DevOps Engineer Course
      Crash Courses
      Programming Training
      • C++ Programming Course
      • Java Course OFFER
      • Python Course
      • UI Development Course
      • AngularJs Course
      • NodeJs Course
      • ReactJs Course
      • Wordpress Course
      • .Net Course TOP
      • Go Programming Course
      • Perl Programming Course
      • C# Programming CourseOFFER
      Business Management Course
      • Microsoft Office Course
      • Excel for Enterprises Course
      Testing Training
      • Selenium Java Course
      • Selenium Python Course
      Security Training
      • Hardware A+ Course
      • Cloud Associate Course
      • Azure Fundamental Course
      • Azure Administrator Course
      Digital Marketing Training
      • Digital Marketing Course
      • SMM Course TOP
      • PPC Expert Course
      • Advanced SEO Course
      • SMO Course OFFER
      DB Management Training
      • MSSQL Course
      • Core MYSQL OFFER
      • Oracle Fundamentals Course
      • Oracle DBA Course
      • Oracle PL SQL Course
      Professional Courses
      Programming Training
      • Programming Course TOP
      • Advanced Java Course
      • Advanced Python Course
      Full Stack Training
      • MERN Stack Course
      • MEAN Stack Course
      • Python Full Stack Course
      • Java Full Stack Course
      • PHP Full Stack Course
      • .Net Full Stack Course
      • JS Family Full Stack Course
      Mobile App Training
      • Android Course
      • IOS CourseOFFER
      • Flutter & Dart Course
      • React Native CourseOFFER
      Cyber Security Training
      • Hacking Defender Course
      • Security+ Course
      • Security Analyst+ Course
      • Elynux Essentials Course
      Networking Training
      • CCNA - Cisco Solutions
      • CCNP - Switching , Routing
      • Hardware A+ & Network N+
      DB Management Training
      • MySQL & MSSQL Course
      • Oracle DB Management
      Software Test Training
      • Software Test Expert Course TOP
      • Automation Testing TOP
      Data Science & Analyst
      • Python for Data Science-ML
      • DA- (R,Tableau & Power BI)
      Cloud Computing Training
      • Cloud Solution Architect Course
      • DevOps Professional Course
      • Cloud DevOps Engineer Course
      SAP Training
      • Finance & Controlling
      • Materials Management
      • Human Capital Management
      • Advanced Business App Programming
      • High-Performance Analytic Appliance
      Crash Courses
      Programming Training
      • C & C++ Programming Course
      • Java Course OFFER
      • Python Course
      • Core PHP Course
      • UI Development Course
      • AngularJs Course
      • NodeJs Course
      • ReactJs Course
      • Wordpress Course
      • .Net Course TOP
      • Go Programming Course
      • Perl Programming Course
      • C# Programming CourseOFFER
      Business Management Course
      • Microsoft Office Course
      • Excel for Enterprises Course
      Testing Training
      • Selenium Java Course
      • Selenium Python Course
      • Manual Tester - ISTQB Course
      Security Training
      • Hardware A+ Course
      • Cloud Associate Course
      • Azure Fundamental Course
      • Azure Administrator Course
      Digital Marketing Training
      • Digital Marketing Course
      • SMM Course TOP
      • PPC Expert Course
      • Advanced SEO Course
      • SMO Course OFFER
      DB Management Training
      • MSSQL Course
      • Core MYSQL OFFER
      • Oracle Fundamentals Course
      • Oracle DBA Course
      • Oracle PL SQL Course
      AI Mastery Program
      • AI Engineering For Developers
      • AI Power Digital Marketing
      • AI Mastery For Entrepreneurs Programme
  • Support
    • Placement Training
    • Career Guidance
    • Appointment Booking
    • Help Center
    • Tech Blog
    • Elysium Spark Notes
    • MicroBookShelf
    • Elysium CodeSheet
    • Interview Question
    • Download
    • Ask Elsa
    • Franchise Oppurtunity 
    • Classmate App
  • Contact Us
      • Madurai
      • Chennai - CIT Nagar
      • Tirunelveli
      • Virudhunagar
      • Perambalur
      • Trichy
      • Theni
      • Coimbatore - Hopes
      • Hosur
      • Tiruppur
      • Thoothukudi

      Contact Us

      • 227, IInd Floor, B Block, Elysium Campus, Church Rd, Anna Nagar, Madurai, Tamil Nadu 625020
      • 096777 81155, 096777 24437
      • +91 (0452) 4353702
      • info@elysiumacademy.org
      Madurai
      View More

      Contact Us

      • 12,North Road, near Nandhi Statue,CIT Nagar West, Chennai,Tamilnadu 600035
      • 9941161919
      • 089393 90929
      • chn.cit@elysiumacademy.org
      Chennai
      View More

      Contact Us

      • Castro Palace, 48/5, S Bypass Rd, Xavier Colony, Vasanth Nagar, Tirunelveli, Tamil Nadu 627005
      • 09488126688
      • tnv@elysiumacademy.org
      Tirunelveli
      View More

      Contact Us

      • 1/2A, AA Road, near Head Post Office, MGR Nagar, Anna Nagar, Virudhunagar, Tamil Nadu 626001
      • 08903390051
      • vnr@elysiumacademy.org
      Viruthunagar
      View More

      Contact Us

      • 1/2A, AA Road, near Head Post Office, MGR Nagar, Anna Nagar, Virudhunagar, Tamil Nadu 626001
      • 08903390051
      • vnr@elysiumacademy.org
      • Open 24 Hours
      Madurai
      View More

      Contact Us

      • 2nd Floor, Ponmanam Plaza, above Reliance Trends, near New Bus Stand, Thuraimangalam, Perambalur, Tamil Nadu 621212
      • +91 94422 20202
      • pbr@elysiumacademy.org
      Perambalur
      View More

      Contact Us

      • 2nd Floor, Jaishree Towers, C-142, 9A Cross Rd, above SBI Bank6th Cross East, Thillai Nagar East, West Thillai Nagar, Tennur, Tiruchirappalli, Tamil Nadu 620018
      • +91 9952887895
      • try@elysiumacademy.org
      tiruchy
      View More

      Contact Us

      • D. No.635/A, 3rd Floor, Near State Bank of India, Periyakulam Road, Theni
      • 78978 94002
      • 78978 95002
      • teni@elysiumacademy.org
      contact theni img
      View More

      Contact Us

      • 62, Suriya Complex, Gandhi Street, Thaneerpanthal Road, BR Puram, Hope College,
        Coimbatore -641 004. Landmark – Opp GRG School Ground
      • +91 96777 04758
      • +91 96777 04785
      • cbe.hopes@elysiumacademy.org
      contact cbe hopes img
      View More

      Contact Us

      • First Floor, No. 16, F/8, Hosur - Krishnagiri Rd, adjacent to Ameeria petrol bunk, Hosur, Tamil Nadu 635109
      • +91 993637 73741
      • hsr@elysiumacademy.org
      contact hosur img
      View More

      Contact Us

      • No.9/3C, Mariamman koil street, Padmavathipuram, SAP Theatre opposite, Tiruppur - 641603.
      • +91 7397391713
      • +91 7397391318
      • tup@elysiumacademy.org
      software training institutes
      View More

      Contact Us

      • 127, Ettayapuram Road, Melur Tuticorin, Tuticorin Central Police Station, Thoothukudi - 628002
      • +9193841 34008
      • +9193841 64008
      • ttk@elysiumacademy.org
      Contact -Tuticorin
      View More
  • About Us
    • Academy Overview
    • Mission & Vision
    • Foot Steps
    • Our Pillars
    • Gallery
    • Testimonials
      • Video Testimonials
      • Reviews
    • Our Awards
  • Tesbo Courses
      Tesbo Courses PREMIUM
      • Full Stack JS Programmer Course
      • Full Stack Core Programmer
      • Full Stack Native Programmer
      • Data Analyst CourseOFFER
      • Testing Expert CourseOFFER
      • Mobile App Developer Course
      • IT Infra Manager
      • Cloud Architect Course
      • DevOps Engineer Course
      • Digital Marketing CourseOFFER
      Slash CoursesBUDGET
      • Core C & C++ Coures
      • Core Java & Concepts Course
      • Core Python & Concepts Course OFFER
      • Core UI Development Course
      • Microsoft Office Course
      • CompTIA – Hardware A+ Course
      Classic Courses BUDGET
      • Core C & C++ Coures
      • Core Java & Concepts Course
      • Core Python & Concepts Course OFFER
      • Core MSSQL Course
      • Digital Marketing Courses
      mega-menu
  • Professional Course
      Professional Courses
      Programming Training
      • Programming Course TOP
      • Advanced Java Course
      • Advanced Python Course
      Full Stack Training
      • MERN Stack Course
      • MEAN Stack Course
      Mobile App Training
      • Android Course
      • IOS CourseOFFER
      • Flutter & Dart Course
      • React Native CourseOFFER
      Cyber Security Training
      • Hacking Defender Course
      • Security+ Course
      • Security Analyst+ Course
      • Elynux Essentials Course
      Networking Tranining
      • CCNA - Cisco Solutions
      • CCNP - Switching , Routing
      • Hardware A+ & Network N+
      DB Management Training
      • MySQL & MSSQL Course
      • Oracle DB Management
      Software Testing
      • ISTQB Course TOP
      • Automation Testing TOP
      Data Science & Analyst
      • Python for Data Science-ML
      • DA- (R,Tableau & Power BI)
      Cloud Computing Training
      • Cloud Practioner Course
      • Cloud Solution Architect Course
      • DevOps Professional Course
      • Cloud DevOps Engineer Course
      Crash Courses
      Programming Training
      • C++ Programming Course
      • Java Course OFFER
      • Python Course
      • UI Development Course
      • AngularJs Course
      • NodeJs Course
      • ReactJs Course
      • Wordpress Course
      • .Net Course TOP
      • Go Programming Course
      • Perl Programming Course
      • C# Programming CourseOFFER
      Business Management Course
      • Microsoft Office Course
      • Excel for Enterprises Course
      Testing Training
      • Selenium Java Course
      • Selenium Python Course
      Security Training
      • Hardware A+ Course
      • Cloud Associate Course
      • Azure Fundamental Course
      • Azure Administrator Course
      Digital Marketing Training
      • Digital Marketing Course
      • SMM Course TOP
      • PPC Expert Course
      • Advanced SEO Course
      • SMO Course OFFER
      DB Management Training
      • MSSQL Course
      • Core MYSQL OFFER
      • Oracle Fundamentals Course
      • Oracle DBA Course
      • Oracle PL SQL Course
      Professional Courses
      Programming Training
      • Programming Course TOP
      • Advanced Java Course
      • Advanced Python Course
      Full Stack Training
      • MERN Stack Course
      • MEAN Stack Course
      • Python Full Stack Course
      • Java Full Stack Course
      • PHP Full Stack Course
      • .Net Full Stack Course
      • JS Family Full Stack Course
      Mobile App Training
      • Android Course
      • IOS CourseOFFER
      • Flutter & Dart Course
      • React Native CourseOFFER
      Cyber Security Training
      • Hacking Defender Course
      • Security+ Course
      • Security Analyst+ Course
      • Elynux Essentials Course
      Networking Training
      • CCNA - Cisco Solutions
      • CCNP - Switching , Routing
      • Hardware A+ & Network N+
      DB Management Training
      • MySQL & MSSQL Course
      • Oracle DB Management
      Software Test Training
      • Software Test Expert Course TOP
      • Automation Testing TOP
      Data Science & Analyst
      • Python for Data Science-ML
      • DA- (R,Tableau & Power BI)
      Cloud Computing Training
      • Cloud Solution Architect Course
      • DevOps Professional Course
      • Cloud DevOps Engineer Course
      SAP Training
      • Finance & Controlling
      • Materials Management
      • Human Capital Management
      • Advanced Business App Programming
      • High-Performance Analytic Appliance
      Crash Courses
      Programming Training
      • C & C++ Programming Course
      • Java Course OFFER
      • Python Course
      • Core PHP Course
      • UI Development Course
      • AngularJs Course
      • NodeJs Course
      • ReactJs Course
      • Wordpress Course
      • .Net Course TOP
      • Go Programming Course
      • Perl Programming Course
      • C# Programming CourseOFFER
      Business Management Course
      • Microsoft Office Course
      • Excel for Enterprises Course
      Testing Training
      • Selenium Java Course
      • Selenium Python Course
      • Manual Tester - ISTQB Course
      Security Training
      • Hardware A+ Course
      • Cloud Associate Course
      • Azure Fundamental Course
      • Azure Administrator Course
      Digital Marketing Training
      • Digital Marketing Course
      • SMM Course TOP
      • PPC Expert Course
      • Advanced SEO Course
      • SMO Course OFFER
      DB Management Training
      • MSSQL Course
      • Core MYSQL OFFER
      • Oracle Fundamentals Course
      • Oracle DBA Course
      • Oracle PL SQL Course
      AI Mastery Program
      • AI Engineering For Developers
      • AI Power Digital Marketing
      • AI Mastery For Entrepreneurs Programme
  • Support
    • Placement Training
    • Career Guidance
    • Appointment Booking
    • Help Center
    • Tech Blog
    • Elysium Spark Notes
    • MicroBookShelf
    • Elysium CodeSheet
    • Interview Question
    • Download
    • Ask Elsa
    • Franchise Oppurtunity 
    • Classmate App
  • Contact Us
      • Madurai
      • Chennai - CIT Nagar
      • Tirunelveli
      • Virudhunagar
      • Perambalur
      • Trichy
      • Theni
      • Coimbatore - Hopes
      • Hosur
      • Tiruppur
      • Thoothukudi

      Contact Us

      • 227, IInd Floor, B Block, Elysium Campus, Church Rd, Anna Nagar, Madurai, Tamil Nadu 625020
      • 096777 81155, 096777 24437
      • +91 (0452) 4353702
      • info@elysiumacademy.org
      Madurai
      View More

      Contact Us

      • 12,North Road, near Nandhi Statue,CIT Nagar West, Chennai,Tamilnadu 600035
      • 9941161919
      • 089393 90929
      • chn.cit@elysiumacademy.org
      Chennai
      View More

      Contact Us

      • Castro Palace, 48/5, S Bypass Rd, Xavier Colony, Vasanth Nagar, Tirunelveli, Tamil Nadu 627005
      • 09488126688
      • tnv@elysiumacademy.org
      Tirunelveli
      View More

      Contact Us

      • 1/2A, AA Road, near Head Post Office, MGR Nagar, Anna Nagar, Virudhunagar, Tamil Nadu 626001
      • 08903390051
      • vnr@elysiumacademy.org
      Viruthunagar
      View More

      Contact Us

      • 1/2A, AA Road, near Head Post Office, MGR Nagar, Anna Nagar, Virudhunagar, Tamil Nadu 626001
      • 08903390051
      • vnr@elysiumacademy.org
      • Open 24 Hours
      Madurai
      View More

      Contact Us

      • 2nd Floor, Ponmanam Plaza, above Reliance Trends, near New Bus Stand, Thuraimangalam, Perambalur, Tamil Nadu 621212
      • +91 94422 20202
      • pbr@elysiumacademy.org
      Perambalur
      View More

      Contact Us

      • 2nd Floor, Jaishree Towers, C-142, 9A Cross Rd, above SBI Bank6th Cross East, Thillai Nagar East, West Thillai Nagar, Tennur, Tiruchirappalli, Tamil Nadu 620018
      • +91 9952887895
      • try@elysiumacademy.org
      tiruchy
      View More

      Contact Us

      • D. No.635/A, 3rd Floor, Near State Bank of India, Periyakulam Road, Theni
      • 78978 94002
      • 78978 95002
      • teni@elysiumacademy.org
      contact theni img
      View More

      Contact Us

      • 62, Suriya Complex, Gandhi Street, Thaneerpanthal Road, BR Puram, Hope College,
        Coimbatore -641 004. Landmark – Opp GRG School Ground
      • +91 96777 04758
      • +91 96777 04785
      • cbe.hopes@elysiumacademy.org
      contact cbe hopes img
      View More

      Contact Us

      • First Floor, No. 16, F/8, Hosur - Krishnagiri Rd, adjacent to Ameeria petrol bunk, Hosur, Tamil Nadu 635109
      • +91 993637 73741
      • hsr@elysiumacademy.org
      contact hosur img
      View More

      Contact Us

      • No.9/3C, Mariamman koil street, Padmavathipuram, SAP Theatre opposite, Tiruppur - 641603.
      • +91 7397391713
      • +91 7397391318
      • tup@elysiumacademy.org
      software training institutes
      View More

      Contact Us

      • 127, Ettayapuram Road, Melur Tuticorin, Tuticorin Central Police Station, Thoothukudi - 628002
      • +9193841 34008
      • +9193841 64008
      • ttk@elysiumacademy.org
      Contact -Tuticorin
      View More
C++ Programming

C++ Programming

  • October 14, 2024
  • Com 0
C++-Programming

1. C++ Basics

C++ is a compiled language, meaning you write source code, compile it to machine code using a compiler (like GCC or Clang), and then execute the compiled program.
Basic C++ Program:

Copy Code Copied Use a different Browser

#include <iostream>   // Include input/output library
int main() {
    std::cout << "Hello, World!" << std::endl;  // Print message to console
    return 0;   // Return 0, indicating successful program termination
}
Key Points:

  1. #include <iostream>: This includes the Input/Output stream library, which allows us to use std::cout and std::cin.
  2. main() Function: The entry point for any C++ program. The int return type signifies the exit status of the program.
  3. std::cout: Standard output stream, used for printing to the console.
  4. std::endl: Ends the current line and flushes the output buffer.

2. Data Types

C++ provides a wide variety of data types for different purposes, including primitive and user-defined data types.
Primitive Data Types:

Type Description Example
int Integer numbers int age = 25;
float Floating-point numbers float weight = 60.5;
double Double-precision float double pi = 3.14159;
char Single character char grade = ‘A’;
bool Boolean (True/False) bool isHappy = true;
void Represents no type or void Used in functions with no return value

Modifiers for Data Types:

  1. Signed/Unsigned: Modifies integer types to include negative numbers or only positive numbers.
  2. Short/Long: Modifies integer types to reduce or extend their storage capacity.
Copy Code Copied Use a different Browser

short int shortNumber = 10;    // Uses less memory
unsigned int positiveNumber = 42;  // Only stores positive values
long long int largeNumber = 9223372036854775807;
User-Defined Data Types:

  1. struct: Used to group different data types together.
  2. enum: Used to define an enumeration (a set of named integral constants).
Copy Code Copied Use a different Browser

struct Person {
int age;
char gender;
};
enum Day { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday };

3. Variables and Constants

Variable Declaration:
Variables in C++ must be declared before they are used, specifying their type.

Copy Code Copied Use a different Browser

int age = 25;            // Integer variable
float temperature = 36.6;  // Float variable
char initial = 'J';      // Character variable
bool isStudent = true;   // Boolean variable
Constants:
Constants in C++ are immutable and can be defined using the const keyword.
Copy Code Copied Use a different Browser

const double PI = 3.14159;  // Constant value, cannot be changed
Alternatively, constants can also be defined using #define.
Copy Code Copied Use a different Browser

#define MAX_SIZE 100

4. Operators in C++

C++ supports a wide variety of operators for performing operations on variables.
Arithmetic Operators:

Operator Description Example
+ Addition a + b
– Subtraction a – b
* Multiplication a * b
/ Division a / b
% Modulus (Remainder) a % b

Relational Operators:

Operator Description Example
== Equal to a == b
!= Not equal to a != b
> Greater than a > b
< Less than a < b
>= Greater or equal a >= b
<= Less or equal a <= b

Logical Operators:

Operator Description Example
&& Logical AND a && b
` `
! Logical NOT !a

Assignment Operators:

Operator Description Example
= Assign value a = b
+= Add and assign a += b
-= Subtract and assign a -= b
*= Multiply and assign a *= b
/= Divide and assign a /= b

Increment/Decrement Operators:

Operator Description Example
++a Pre-increment (before use) ++a
a++ Post-increment (after use) a++
–a Pre-decrement (before use) –a
a– Post-decrement (after use) a–

5. Control Structures

C++ provides control structures like conditional statements and loops to control the flow of execution in programs.
If-Else Statement:

Copy Code Copied Use a different Browser

if (age >= 18) {
std::cout << "Adult";
} else {
std::cout << "Minor";
}
Switch Case:
Copy Code Copied Use a different Browser

int day = 3;
switch (day) {
case 1: std::cout << "Monday"; break;
case 2: std::cout << "Tuesday"; break;
case 3: std::cout << "Wednesday"; break;
default: std::cout << "Another day";
}
Ternary Operator:
Copy Code Copied Use a different Browser

std::string result = (age >= 18) ? "Adult" : "Minor";

6. Loops

Loops allow repetitive execution of a block of code.
For Loop:

Copy Code Copied Use a different Browser

for (int i = 0; i < 5; i++) {
std::cout << i << std::endl;
}
While Loop:
Copy Code Copied Use a different Browser

int i = 0;
while (i < 5) {
std::cout << i << std::endl;
i++;
}
Do-While Loop:
Copy Code Copied Use a different Browser

int i = 0;
do {
std::cout << i << std::endl;
i++;
} while (i < 5);
Break and Continue:

  1. break: Exits a loop immediately.
  2. continue: Skips the current iteration and moves to the next one.
Copy Code Copied Use a different Browser

for (int i = 0; i < 10; i++) {
if (i == 5) break;
if (i % 2 == 0) continue;
std::cout << i << std::endl;
}

7. Functions in C++

Functions allow code to be modular, reusable, and easier to understand.
Defining and Calling Functions:

Copy Code Copied Use a different Browser

int add(int a, int b) {
return a + b;
}
int main() {
int sum = add(5, 3);   // Function call
std::cout << sum;      // Outputs 8
}
Default Parameters:
Copy Code Copied Use a different Browser

int add(int a, int b = 10) {
return a + b;
}
int main() {
std::cout << add(5);  // Outputs 15
}
Pass by Value and Reference:

  1. Pass by Value: The actual value is passed, changes to the parameter inside the function have no effect on the actual argument.
  2. Pass by Reference: The reference of the variable is passed, changes to the parameter affect the actual argument.
Copy Code Copied Use a different Browser

void changeValue(int& x) {   // Pass by reference
x = 100;
}
int main() {
int a = 5;
changeValue(a);
std::cout << a;  // Outputs 100
}

8. Arrays 

Arrays in C++ are used to store multiple values of the same data type.
Declaring Arrays:

Copy Code Copied Use a different Browser

int numbers[5] = {1, 2, 3, 4, 5};  // Array with 5 integers
Accessing Array Elements:
Copy Code Copied Use a different Browser

int first = numbers[0];   // Access first element
numbers[2] = 10;          // Modify the third element
Multidimensional Arrays:
Copy Code Copied Use a different Browser

int matrix[2][3] = { {1, 2, 3}, {4, 5, 6} };  // 2x3 matrix
Iterating Arrays:
Copy Code Copied Use a different Browser

for (int i = 0; i < 5; i++) {
std::cout << numbers[i] << std::endl;
}

9. Pointers and References

C++ provides powerful memory manipulation features through pointers and

Copy Code Copied Use a different Browser

int a = 5;
int* p = &a;   // Pointer to integer 'a'
std::cout << *p;  // Dereferencing, outputs 5
references.
Pointers:
A pointer is a variable that stores the memory address of another variable.
Copy Code Copied Use a different Browser

int a = 5;
int* p = &a;   // Pointer to integer 'a'
std::cout << *p;  // Dereferencing, outputs 5
  1. & Operator: Gets the address of a variable.
  2. * Operator: Dereferences the pointer, accessing the value at the address.

Pointer Arithmetic:
You can perform arithmetic operations on pointers, such as incrementing them to access the next memory location.

Copy Code Copied Use a different Browser

int arr[3] = {10, 20, 30};
int* ptr = arr;
std::cout << *(ptr + 1);  // Outputs 20
Null Pointers:
A null pointer is a pointer that doesn’t point to any valid address.
Copy Code Copied Use a different Browser

int* ptr = nullptr;
References:
References provide an alternative name for a variable. Unlike pointers, they cannot be null or reassigned after initialization.
Copy Code Copied Use a different Browser

int a = 10;
int& ref = a;   // Reference to variable 'a'
ref = 20;       // Changes the value of 'a'

10. Strings

C++ supports strings through both the C-style character array (char[]) and the std::string class.
C-Style Strings:

Copy Code Copied Use a different Browser

char greeting[] = "Hello, World!";
std::cout << greeting;
std::string Class:
Copy Code Copied Use a different Browser

#include <string>
std::string name = "John";
std::cout << "Hello, " << name << "!";
Common String Operations:
Concatenation:
Copy Code Copied Use a different Browser

std::string firstName = "John";
std::string lastName = "Doe";
std::string fullName = firstName + " " + lastName;
Length:
Copy Code Copied Use a different Browser

std::string str = "Hello";
std::cout << str.length();  // Outputs 5
Substring:
Copy Code Copied Use a different Browser

std::string text = "Hello, World!";
std::string sub = text.substr(0, 5);  // Outputs "Hello"

11. Object-Oriented Programming (OOP)

C++ supports the principles of OOP, such as encapsulation, inheritance, and polymorphism.
Classes and Objects:
A class is a blueprint for creating objects.

Copy Code Copied Use a different Browser

class Dog {
public:
std::string name;
int age;
void bark() {
std::cout << "Woof!" << std::endl;
}
};
int main() {
Dog myDog;
myDog.name = "Buddy";
myDog.age = 3;
myDog.bark();   // Outputs: Woof!
}
Encapsulation:
Data and functions that manipulate that data are encapsulated within a class.
Copy Code Copied Use a different Browser

class Person {
private:
int age;
public:
void setAge(int a) {
age = a;
}
int getAge() {
return age;
}
};
Inheritance:
Inheritance allows one class to inherit properties and methods from another class.
Copy Code Copied Use a different Browser

class Animal {
public:
void eat() {
std::cout << "This animal is eating." << std::endl;
}
};
class Dog : public Animal {
public:
void bark() {
std::cout << "Woof!" << std::endl;
}
};
int main() {
Dog myDog;
myDog.eat();  // Inherited from Animal
myDog.bark(); // Defined in Dog
}
Polymorphism:
Polymorphism allows one interface to be used for a general class of actions, typically achieved through function overloading and overriding.
Copy Code Copied Use a different Browser

class Animal {
public:
virtual void sound() {
std::cout << "Animal sound" << std::endl;
}
};
class Dog : public Animal {
public:
void sound() override {
std::cout << "Woof!" << std::endl;
}
};
int main() {
Animal* animal = new Dog();
animal->sound();  // Outputs: Woof!
}
Constructors and Destructors:

  1. Constructor: A special function that initializes an object when it’s created.
  2. Destructor: A special function that cleans up an object when it’s destroyed.
Copy Code Copied Use a different Browser

class Car {
public:
Car() {
std::cout << "Car created" << std::endl;
}
~Car() {
std::cout << "Car destroyed" << std::endl;
}
};

12. Dynamic Memory Management

C++ allows you to manually manage memory allocation and deallocation using new and delete.
Dynamic Allocation:

Copy Code Copied Use a different Browser

int* p = new int(10);  // Allocates memory for an integer
delete p;              // Deallocates memory
new[] and delete[]: Used to allocate and deallocate arrays.
Copy Code Copied Use a different Browser

int* arr = new int[10];
delete[] arr;

13. Templates

Templates enable generic programming by allowing you to write functions and classes that work with any data type.
Function Template:

Copy Code Copied Use a different Browser

template <typename T>
T add(T a, T b) {
return a + b;
}
int main() {
std::cout << add<int>(5, 3);      // Outputs 8
std::cout << add<double>(5.5, 2.3);  // Outputs 7.8
}
Class Template:
Copy Code Copied Use a different Browser

template <typename T>
class Box {
public:
T value;
Box(T v) : value(v) {}
T getValue() { return value; }
};
int main() {
Box<int> intBox(123);
std::cout << intBox.getValue();  // Outputs 123
}

14. Standard Template Library (STL)

The STL provides a collection of useful data structures and algorithms.
Common Containers:
Vector: Dynamic array.

Copy Code Copied Use a different Browser

#include <vector>
std::vector<int> nums = {1, 2, 3, 4, 5};
Map: Key-value pairs.
Copy Code Copied Use a different Browser

#include <map>
std::map<std::string, int> ages;
ages["John"] = 30
;
Set: Unique collection of elements.
Copy Code Copied Use a different Browser

#include <set>
std::set<int> uniqueNums = {1, 2, 3, 4};
Stack: LIFO (Last In, First Out).
Copy Code Copied Use a different Browser

#include <stack>
std::stack<int> s;
s.push(10);
s.push(20);
Common Algorithms:
STL provides algorithms like sort(), find(), reverse(), etc.
Copy Code Copied Use a different Browser

#include <algorithm>
#include <vector>
std::vector<int> nums = {4, 1, 3, 5, 2};
std::sort(nums.begin(), nums.end());  // Sorts in ascending order

15. Exception Handling

C++ provides support for exception handling using try, catch, and throw blocks.
Try-Catch Block:

Copy Code Copied Use a different Browser

try {
int result = 10 / 0;  // Division by zero
} catch (const std::exception& e) {
std::cout << "Error: " << e.what() << std::endl;
}
Throwing Exceptions:
Copy Code Copied Use a different Browser

throw std::invalid_argument("Invalid argument passed!");

16. Namespaces

Namespaces are used to organize code and avoid name collisions.

Copy Code Copied Use a different Browser

namespace Math {
int add(int a, int b) {
return a + b;
}
}
int main() {
std::cout << Math::add(5, 3);  // Outputs 8
}
Using using Keyword:
Copy Code Copied Use a different Browser

using namespace Math;
std::cout << add(5, 3);  // No need for Math:: prefix

17. Preprocessor Directives

C++ provides several preprocessor directives for code management.

  1. #include: Includes the contents of a file.
  2. #define: Defines constants or macros.
  3. #ifdef / #ifndef: Conditional compilation.
Copy Code Copied Use a different Browser

#define PI 3.14159
#ifdef DEBUG
std::cout << "Debug mode on";
#endif

18. C++ Best Practices

Follow Naming Conventions:

  1. Use camelCase for variables and functions.
  2. Use PascalCase for class names.

Use RAII for Memory Management:

  • Resource Acquisition Is Initialization (RAII) ensures that resources are properly released.

Prefer std::string Over C-Style Strings:

  • std::string handles memory automatically and is easier to use.

Use Smart Pointers:

  • Use std::shared_ptr and std::unique_ptr for automatic memory management and to avoid memory leaks.

Avoid Magic Numbers:

  • Define meaningful constants instead of using raw numbers in your code.

Always Check for Pointer Validity:

  • Ensure pointers are valid before dereferencing them.

Write Modular and Reusable Code:

  • Break large functions into smaller, reusable ones for readability and maintainability.

19. Conclusion

C++ is a robust and versatile language that provides excellent control over system resources, making it ideal for developing high-performance applications. This comprehensive covered fundamental and advanced concepts, from basic syntax and data types to object-oriented programming, memory management, templates, and the Standard Template Library (STL).
As you continue developing in C++, adhering to best practices such as effective memory management, code modularity, and leveraging STL and RAII principles will ensure your C++ programs are efficient, maintainable, and scalable. Happy coding!

Download Elysium Spark Note

Search

Latest Post

Thumb
Python Training in Madurai: The Complete 2026
08 Aug, 2026
Thumb
Generative AI for Managers: Future Skills Every
04 Aug, 2026
Thumb
How to Get a Job After MBA
04 Aug, 2026

Categories

  • ai training
  • Android
  • AWS Training and Certification
  • Azure & Microsoft Technologies
  • Azure Certification
  • azure devops
  • Azure DevOps training in Madurai
  • Azure Services
  • B.Sc Computer Science
  • Bachelor of Business Administration
  • Bachelor of Commerce
  • Bachelor of Computer Application
  • Bachelor of Information Technology
  • Back End Development
  • Big Data Hadoop Training
  • big data revolution
  • Blog Post
  • C Online Course
  • C++ Programming
  • C++ Programming Course
  • Campus on Drive
  • Career Guidance Program
  • Career Opportunities
  • CCNA Certification
  • Cisco Training
  • Cloud Computing
  • Cloud Course
  • Cloud Courses Online
  • coaching classes near me
  • Coding Bootcamps & Courses
  • Computer Courses
  • Computer Engineering
  • Computer Hardware
  • Computer programming courses
  • Content Management Systems
  • Course
  • Cyber Security Course
  • Data Analyst Training course
  • Data Analytics Courses
  • Data Science & Analytics
  • Data science course
  • Database
  • Database Management
  • DevOps & Automation
  • Digital Advertising
  • Digital marketing academy
  • Digital Marketing Course
  • Digital marketing course online
  • Digital Marketing Strategies
  • Education & Learning
  • Education Training
  • Elysium Spark Note
  • Full Stack Developer Course
  • Go programming certification
  • Hacking Course
  • Hacking Defender Training Course
  • Hardware & Infrastructure
  • ISTQB Certification
  • IT Certifications
  • IT Networking Education
  • IT Training
  • IT Training Institute
  • Java Course
  • JavaScript Frameworks
  • Job Oriented Online Courses
  • Machine Learning
  • Master of Business Administration
  • Master of Commerce
  • Master Of Computer Application
  • MEAN Stack Expert Training Course
  • MERN Stack Expert Training Course
  • Microsoft Access Training
  • Mobile App Development Courses
  • Msc Computer Science
  • Networking & IT
  • Networking and Security
  • Networking Fundamentals
  • New Courses
  • Online Courses
  • Online Marketing Courses
  • Oracle Certification
  • Others
  • PPC Strategies
  • Productivity Software
  • Professional Certification Courses
  • Programming & Development
  • Programming Courses
  • Programming Courses
  • Programming Languages
  • Python Programming
  • Python Programming Course
  • React Programming
  • ReactJs Training Course
  • Selenium
  • Selenium computer training
  • Selenium Training
  • SEO Strategies
  • SEO Tools and Software
  • Social Media Marketing
  • Social media marketing course
  • Social Media Strategy
  • Software Development
  • Software Testing
  • Software testing Course Online
  • Software Training
  • Software Training Institute
  • SQL Training
  • Technology
  • Technology & IT Solutions
  • UI/UX Design
  • Uncategorized
  • User Experience (UX)
  • Web Automation
  • Web Designing Course
  • Web Development
  • Website Development
blog_card

Tags

100% job assurance courses advanced digital marketing course advanced Python course aws certification BBA Career BBA Career Courses BBA Certification Courses BBA Certifications BBA Placement BBA Students Best Data science courses Best Data Science Courses Online with Certificates Best full stack development training courses best Java courses Best Python Training and Certification Course Business School Placements career guidance Career Scope cloud computing Data-Driven Decisions Data Skills Data Visualization elysium academy Finance Placements Financial Modeling full stack developer Investment Banking Job Oriented Courses Job Ready Skills MBA 2026 MBA Career Guide MBA Placements Performance Marketing Placement Courses Predictive Analytics professional certification Project Management project management for MBA project manager salary India Python certification course Python Developers Career SAP Course SAP FICO social media marketing workshop
shape
shape-10
shape
EAPL

Unlock New Career Opportunities with an Accredited Certification from Elysium Academy

Get started now
Logo (2)

Elysium Academy provides students with highly effective coaching classes, delivered through immersive classroom sessions and the best teaching methodologies designed to yield valuable results. We take great pride in our identity and are honored to be a part of your business journey.

Icon-facebook Icon-linkedin2 Icon-instagram Pinterest X-twitter Icon-youtube

Company

  • About Us
  • Mission & Vission
  • Blog
  • Reviews
  • Environment Policy
  • Payment Method
  • Our Awards
  • Franchise Oppurtunity
  • Ask Elsa

Student Zone

  • Become an instructor
  • Video Reviews
  • Placed Students
  • Interview Questions
  • Appointment Booking
  • Career Guidance
  • Placement Training
  • Download
  • Help Center
Logo (2)

Elysium Academy provides students with highly effective coaching classes, delivered through immersive classroom sessions and the best teaching methodologies designed to yield valuable results. We take great pride in our identity and are honored to be a part of your business journey.

At Elysium Academy, we deliver high-impact coaching through immersive classroom experiences and advanced teaching methodologies tailored for measurable success. We take immense pride in our unique identity and are privileged to partner with you on your path to professional excellence.

Icon-facebook Icon-linkedin2 Icon-instagram Pinterest X-twitter Icon-youtube

Company

  • About Us
  • Mission & Vission
  • Blog
  • Reviews
  • Environment Policy
  • Payment Method
  • Our Awards
  • Franchise Oppurtunity
  • Ask Elsa

Student Zone

  • Become an instructor
  • Video Reviews
  • Placed Students
  • Interview Questions
  • Appointment Booking
  • Career Guidance
  • Placement Training
  • Download
  • Help Center

Our Branch Locations

  • Elysium Academy - Madurai , Anna Nagar
  • Chennai, CIT Nagar
  • Tirunelveli, Xavier Colony
  • Perambalur, Near New Bus Stand
  • Trichy,Thillainagar
  • Virudhunagar, Anna Nagar
  • Theni , NRT Nagar
  • Coimbatore - Hopes
  • Hosur
  • Tiruppur
  • Thoothukudi

Copyright © Elysium Academy | A Part of Elysium Groups

  • Cookie Policy
  • Terms & Condition
  • Terms of Use
  • Privacy Policy
Logo (2)