Skip to content

Instantly share code, notes, and snippets.


jitpaul/initialization2.cpp Secret

Created Apr 5, 2020
What would you like to do?
#include <vector>
class B{};
class A{
B b;
A(B b):b(b){}
int main(){
A a{B()}; // There is no ambiguity here.
int var1{}; // Zero-initialized to 0;
char* var2{};// Zero-initialized to nullptr;
std::vector v1{}; // Each member is zero-initialized
std::vector v2{1,2,3}; // Vector is initialized with
// 3 elements 1,2 and 3.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment