c++11 - Initializer List Perfomance in C++? -


i totally new programming in c++ , learning constructors. in blog post constructors read before written using "initializer list" better assigning values inside body in class constructor when initialzing class variables due performance reasons. there not explanation reasons behind it. if can explain grateful.

firstly question in not complete. there specific cases indeed. simplicity :

class foo {     exampletype var; public:     foo(exampletype x):var(x) {      } }; 

firstly copy constructor of “exampletype” class called initialize : var(x) destructor of “exampletype” called “x” since goes out. in variable assignment case, firstly constructor called example type assignment operator called , destructor called.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -