Quick Q: Why would I use =default?—StackOverflow

Save to:
Instapaper Pocket Readability

Quick A: Not just for convenience, but sometimes it matters for PODness or optimal performance.

From SO:

The new keyword =default in C++11

I don't understand why would I ever do this:

struct S {
    int a;
    S(int aa) : a(aa) {}
    S() = default;
};

Why not just say:

S() {} // instead of S() = default;

why bring in a new keyword for that?

Add a Comment

You must sign in or register to add a comment.

Comments (0)

There are currently no comments on this entry.