Sitemap
Hello C++

Basic and important C++ knowledge for any C++ developers

Member-only story

C++ Knowledge in Coding Interview

Some useful C++ knowledge and examples that may be used/asked in a coding interview

21 min readOct 14, 2018

--

Press enter or click to view image in full size
Photo by Álvaro Bernal on Unsplash

Table of Contents

  • Variables definitions, assignments, and initiations
  • Type conversions
  • Pointer
  • Object-Oriented Programming
  • STL
  • Other common usages
  • Explanation of keywords

Variables definitions, assignments and initializations

Uniform initializations

Integers

int a;
int a = 5;
int a(5);
int a{5};

Char

char c;
c = 'a';
c = 97; // same as c = 'a'; cout << c will print 'a' as well.
char c = 'a';
char c('a');
char c{'a'};

Float and double

float f;
f = 5.0f;
float f = 5.0f;
float f(5.0f);
float f{5.0f};
double d;
d = 5.0;
double d = 5.0;
double d(5.0);
double d{5.0};

C-style string

char str[] = "string"; //\0 is added automatically
str = "rope"; // not ok!

--

--

Larry | Peng Yang
Larry | Peng Yang

Written by Larry | Peng Yang

Software Engineer in Tokyo. Aim to understand computer science very well. www.buymeacoffee.com/yangpeng. www.linkedin.com/in/yangpeng-tech.

Hello C++
Hello C++

Published in Hello C++

Basic and important C++ knowledge for any C++ developers