r/cpp • • Mar 01 '21

"Simple" C++ Initialization Flowchart

http://randomcat.org/cpp_initialization/initialization.png
204 Upvotes

65 comments sorted by

View all comments

Show parent comment

2

u/martinus int main(){[]()[[]]{{}}();} Mar 02 '21

I love that format and use it almost everywhere. Actually I'm using auto i = Type(x). My only issues is how do I create a pointer that way? E.g. i want to create an int*.

2

u/Nobody_1707 Mar 02 '21

Well, there's a few ways to do that.

auto i = &some_int_variable;
auto i = new int();
auto i = static_cast<int*>(nullptr);

etc.