A

@Adarsh1999

vector array

C++
3 years ago
A std::vector is a container class in the C++ Standard Template Library (STL) that stores a dynamically-sized array of elements. It is similar to an array, but provides additional functionality such as dynamic resizing and automatic memory mana

std array

C++
3 years ago
std::array is a container class that is defined in the <array> header of the C++ Standard Template Library (STL). It is a container that holds a fixed size of elements of a certain type. std::array is similar to an ordinary array, but it has s

lambda

C++
3 years ago
In C++, a lambda function (also known as a lambda expression or anonymous function) is a way to define and create a function without giving it a name. A lambda function is defined by the following syntax: Copy code [capture list](parameter l

static assert

C++
3 years ago
static assart A static_assert is a feature in C++ that allows you to check a condition at compile-time and produce a compile-time error if the condition is not true. It is defined in the <cassert> header and it is used to ensure that certain c

Type traits

C++
3 years ago
Sure, here's a simple example that demonstrates how to use type traits: Copy code #include <iostream> #include <type_traits> int main() { // Check if int is a fundamental type std::cout << "Is int a fundamental type? ";

alias

C++
3 years ago
In C++, alias is a feature introduced in C++11 that allows you to create an alias or alternative name for a type. The using keyword is used to create an alias. Here is an example of how to use alias to create an alias for an existing type: Co

explicit sepecalization

C++
3 years ago
#include <iostream> #include <vector> template<typename T> class PrettyPrinter { T *m_pData; public: PrettyPrinter(T *data) :m_pData(data) { } void Print() {

stack

C++
3 years ago
#include <iostream> template<typename T,int size> class Stack { T m_Buffer[size]; int m_Top{ -1 }; public: Stack() = default; Stack(const Stack<T, size> &obj) { m_Top = obj.m_Top; for (int i = 0; i <= m_Top; ++i) {

Templates array

C++
3 years ago
Here is an example of a full code that demonstrates the use of a template function to calculate the average value of an array: Copy code #include <iostream> template <typename T, size_t N> double average(T(&arr)[N]) { T sum = 0; for (size_

explicit specialization

C++
3 years ago
In C++, templates are a powerful feature that allows you to define functions and classes that can operate on a variety of types. However, sometimes you may want to use a specific type for a template, instead of letting the compiler deduce the type b

templates def basic

C++
3 years ago
In C++, templates are a powerful feature that allow you to write generic code that can work with different types of data. A template is a blueprint for a function or a class that can work with different types of data, without the need to write m

Templates basics

C++
3 years ago
#include <iostream> //Old Code //int Max(int x, int y) { // return x > y ? x : y; //} //float Max(float x, float y) { // return x > y ? x : y; //} //Primary Template

Binary files

C++
3 years ago
#include <iostream> #include <fstream> #include <string> struct Record { int id; char name[10]; }; void WriteRecord(Record *p) { std::ofstream binstream{ "records", std::ios::binary | std::ios::out }; binstream.write((const char *)p, si

binary copy file

C++
3 years ago
In C++, you can use the fstream library to copy one file to another. Here is an example of how to do this: Copy code #include <iostream> #include <fstream> using namespace std; int main() { // Open the files

File read write

C++
3 years ago
In C++, there are several ways to read and write to files. Here's an example of how to read and write to a file using the C++ standard library's fstream library, which is considered a more recent and optimized way of performing file I/O operatio

filesystem library

C++
3 years ago
/* The C++ standard library includes a filesystem library, which is part of the C++17 standard and later. This library provides various classes and functions for working with file systems and directories, such as creating, copying, and deleting fil

Exception with pointer

C++
3 years ago
In C++, there are several types of smart pointers that can be used with exception handling. One of the most common is the std::unique_ptr, which is a part of the C++ Standard Template Library (STL). A simple example of using std::unique_ptr wi

Exception 2fn

C++
3 years ago
#include <iostream> #if 0 /*It's worth noting that C++ provides several standard exception classes such as std::invalid_argument, std::domain_error, std::out_of_range, std::length_error, std::range_error, std::overflow_error, std::underflow_error,

Exception handling

C++
3 years ago
#if 0 In C++, an exception is a event that occurs during the execution of a program that disrupts the normal flow of instructions. When an exception is thrown, the program searches for a matching exception handler to handle it. The keyword "throw" i

vector basics

C++
3 years ago
std::vector is a container class template in the C++ Standard Template Library (STL). It is a dynamic array that can grow or shrink in size as needed. std::vector is defined in the <vector> header file. Here are some examples of how std::vector c