
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7197 Articles for C++

3K+ Views
You should really be using a library to parsing CSV files in C++ as there are many cases that you can miss if you read files on your own. The boost library for C++ provides a really nice set of tools for reading CSV files. For example, example#include vector parseCSVLine(string line){ using namespace boost; std::vector vec; // Tokenizes the input string tokenizer tk(line, escaped_list_separator ('\', ', ', '\"')); for (auto i = tk.begin(); i!=tk.end(); ++i) vec.push_back(*i); return vec; } int main() { std::string line = "hello, from, ... Read More

8K+ Views
You can set clear and toggle bits using bitwise operators in C, C++, Python, and all other programming languages that support these operations. You also need to use the bitshift operator to get the bit to the right place.Setting a bitTo set a bit, we'll need to use the bitwise OR operator −Example#include using namespace std; int main() { int i = 0, n; // Enter bit to be set: cin >> n; i |= (1 > n; i ^= (1

784 Views
In C++, floating-point numbers are used to represent decimal values. The most commonly used floating-point types are float and double. These data types differ in their size, precision, and use cases. Understanding how to use and compare them correctly is important for accurate computations. Understanding Float and Double Precision The float is a 32-bit single-precision floating-point type that can store approximately 7 decimal digits, while double is a 64-bit double-precision type that offers about 15 to 16 digits of precision. Due to these differences, double is generally preferred for higher accuracy in scientific and financial calculations. Example: Printing ... Read More

1K+ Views
You can't access a local variable once it goes out of scope. This is what it means to be a local variable. Though, Let us look at an example where you MIGHT be able to access a local variable's memory outside its scope.Example#include int* foo() { int x = 3; return &x; } int main() { int* address = foo(); cout

17K+ Views
Singleton design pattern is a software design principle that is used to restrict the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. For example, if you are using a logger, that writes logs to a file, you can use a singleton class to create such a logger. You can create a singleton class using the following code −Example#include using namespace std; class Singleton { static Singleton *instance; int data; // Private constructor so that no objects can be created. ... Read More

4K+ Views
const_castcan be used to remove or add const to a variable. This can be useful if it is necessary to add/remove constness from a variable.static_castThis is used for the normal/ordinary type conversion. This is also the cast responsible for implicit type coersion and can also be called explicitly. You should use it in cases like converting float to int, char to int, etc.dynamic_castThis cast is used for handling polymorphism. You only need to use it when you're casting to a derived class. This is exclusively to be used in inheritence when you cast from base class to derived class.reinterpret_castThis is ... Read More

131 Views
You can find the current C standard documents on ANSI web store. https://webstore.ansi.org/RecordDetail.aspx?sku=INCITS%2FISO%2FIEC+9899-2012You can find the current C++ standard documents on the ISO C++ website for buying − https://www.iso.org/standard/68564.htmlThe working draft of the ISO C++ standard is also available on https://isocpp.org/std/the-standard

413 Views
A smart pointer is a class that wraps a 'raw' (or 'bare') C++ pointer. It is used to manage resources the pointer points to. For example, if the reference to that memory location is lost. It kind of acts like a garbage collector. There are multiple smart pointer types.You should almost always use a smart pointer. This is because the main pain point of using pointers is manual memory management and memory leaks. The smart pointer tries to get rid of both of these. If you don't want to do either of these in practice, you should use a smart ... Read More

231 Views
Forward declaration lets the code following the declaration know that there is are classes with the name Person. This satisfies the compiler when it sees these names used. Later the linker will find the definition of the classes. exampleClass Person; void myFunc(Person p1) { // ... } Class Person { // Class definition here };So in this case when compiler encounters myFunc, it'll know that its going to encounter this class somewhere down in the code. This can be used in cases where code using the class is placed/included before the code containing the class definition.

201 Views
Arrays and pointers work quite similarly in C/C++. But there are some subtle differences. For example, the sizeof operator works quite differently on the two. When you convert an array in a pointer,Example#include int main() { const int a[] = { 2, 3, 5, 7, 11 }; const int* p = a; std::cout