Performance depends on the underlying stream buffer.

  1. standard input
  2. standard output
  3. standard error

Difference between fully buffered, unbuffered and line buffered stream

For fully buffered stream, characters are accumulated…


C++11 thread = native thread + language specifications


std::optional is a type wrapper which wraps that type and an optional flag which says about the nullability of that type.

  • a pointer with value nullptr is a pointer that points to no location.
  • an id type with an allowed value of 0, which says the id is invalid if 0 or it’s a valid if more than 0.
unsigned int getId(const std::string &name)
{
if (name == "test") {
return 1;
}

if (name == "foo") {
return 2;
}

return 0;
}
int main()
{
std::vector<std::string> names…

Structured binding allows you to initialize multiple variables with individual elements of a structure, tuple, or array.

Photo by luis gomes from Pexels


relationship between different objects



RAII is one of the patterns in C++ to manage resources.

template <typename T, std::size_t N>
T* allocateMemory()
{
return new T[N];
}
template <typename T>
void freeMemory(T *p)
{
delete[] p;
}
int main()
{
int *p = allocateMemory<int, 10>();
// use p
freeMemory(p);

return 0;
}
  1. allocateMemory() is not called at all. Then the program will crash.
  2. freeMemory() is not called at all. There will be memory leak.
  3. freeMemory() is called twice from two different control paths or threads. It will cause double deletion and might crash.



  1. Row
  2. Column
  3. Grid
  4. Flow

Asit Dhal

C++11/14, Qt, Juce

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store