Welcome to the C++ Programming Repository! This repository contains a collection of C++ programs that cover both fundamental and advanced topics in C++. Whether you're a beginner looking to learn the basics or an intermediate learner looking for practical examples, this repository can assist.
- Lab 1: Basics of C++
- Lab 2: Functions, Pointers, and References
- Lab 3: Classes and Objects
- Lab 4: Constructors and Destructors
- Lab 5: Operator Overloading
- Lab 6: Advanced Operator Overloading
- Lab 7: Data Conversion
- Lab 8: Inheritance
- Lab 9: Polymorphism and Virtual Functions
- Lab 10: Templates and Exception Handling
- Lab 11: File Handling
- Lab 12: Binary File Operations
Concepts Covered: Hello World, Variables, Control Structures, Scope Resolution
#include<iostream>
using namespace std;
int main() {
cout << "Hello World!";
return 0;
}
Description: this first C++ program! Prints "Hello World!" to the console.
-
Maximum of 5 Numbers Description: Finds the largest number among five user inputs using conditional statements.
-
Geometric Calculator Question: Calculate the area and perimeter of a circle, rectangle, and square. Quesion: Code calculatesthe area/circumference of shapes using user inputs.
-
Student Record Formatter Description: Stores and displays names/addresses of two students with formatted output.
-
Even/Odd Checker Description: Determines if a number is even or odd using the modulus operator %.
This lab explores advanced function concepts and memory management.
-
Dynamic Memory Allocation (DMA)
- Learn to use
new
anddelete
operators for memory management.
- Learn to use
-
Pass by Reference
- Demonstrates passing variables by reference to functions.
-
Return by Reference
- Uses references to return values from functions.
-
Inline Functions
- Shows how to define and use inline functions for efficiency.
-
Default Arguments in Functions
- Demonstrates the use of default values in function parameters.
-
Namespaces and Using Directives
- Introduces namespaces to avoid name conflicts.
-
Const Arguments
- Shows how to use constant arguments to ensure immutability.
-
Function Overloading
- Demonstrates how to use the same function name for different parameter lists.
-
Pointers
- Covers the basics of pointers and their operations.
-
Pointers and Arrays
- Explains the relationship between pointers and arrays.
This lab focuses on Object-Oriented Programming (OOP) concepts.
-
Rectangle Class
- Defines a
Rectangle
class with length and width and calculates the area.
- Defines a
-
Student Class
- Includes methods to set and get student details and calculate average marks.
-
Bank Account Class
- Implements a basic banking system with deposit, withdrawal, and balance check functionalities.
-
Coordinate Addition
- Demonstrates the addition of two coordinate objects.
-
Nested Member Functions
- Explains the concept of nested functions within a class.
-
Time Class
- Performs operations like addition of time using various passing mechanisms (value, reference, address).
-
Largest Number with Default Constructor
- Finds the largest number using a default constructor.
-
Armstrong Number Check
- Verifies if a number is an Armstrong number using a default constructor.
-
Rectangle Area Calculation
- Calculates the area of a rectangle with a constructor defined outside the class.
-
Parameterized Constructor Examples
- Various programs to demonstrate parameterized constructors.
-
Copy Constructor and Destructor
- Examples of copy constructors and destructors.
-
Overloading Increment Operators
- Implements pre- and post-increment for an
Time
object.
- Implements pre- and post-increment for an
-
Matrix Addition and Multiplication
- Overloads
+
and*
operators for matrix operations.
- Overloads
-
Binary Operator Overloading
- Adds two objects using overloaded binary operators.
-
String Concatenation
- Concatenates strings using operator overloading.
-
Relational Operator Overloading
- Demonstrates overloading comparison operators.
-
Stream Operator Overloading
- Implements
<<
and>>
for custom I/O operations.
- Implements
- Basic to User-Defined Type
- User-Defined to Basic Type
- User-Defined to User-Defined Type
- Single Inheritance
- Constructor in Base Class
- Multiple Inheritance
- Constructor in Multiple Inheritance
- Virtual Functions
- Pure Virtual Functions
- Virtual Destructors
- Virtual Base Class
- Function Templates
- Class Templates
- Basic Exception Handling
- Exception Classes
- Write to Disk File
- Read from Disk File
- **File I/O with **
fstream
- Write and Read Variables in Binary Mode
- Write and Read Objects in Binary Files
- Clone the repository:
git clone https://github.com/Madhav-Paudel/Cplusplus-_programming.git
- Navigate to the desired lab folder.
- Explore the examples and practice the concepts.
- Each example follows modern C++ conventions
- Code is thoroughly commented
- Error handling is implemented
- Memory management is properly handled
- Object-oriented principles are followed
Common issues and solutions:
- Compiler errors: Make sure you're using C++17 or later
- Memory leaks: Use smart pointers where possible
- Build errors: Check for missing dependencies
- Runtime errors: Enable debug mode for detailed error messages
- Modern C++ community
- Contributors to this repository
- C++ Standard Committee for language features
- C++ compiler (g++ recommended)
- C++17 or later
- Basic understanding of programming concepts
- Code editor (VS Code, CLion, etc.)
Cplusplus-_programming/
├── Lab1/
│ ├── hello_world.cpp
│ ├── calculator.cpp
│ └── geometric.cpp
├── Lab2/
│ ├── functions/
│ └── pointers/
├── Lab3/
│ ├── classes/
│ └── objects/
└── ...
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Created by Madhav Paudel - Feel free to connect!