Skip to main content

Problem #1

Posted in

struct S {
    static int i;
 
    S() { ++i; }
    S(const S&) { ++i; }
};
 
int S::i = 0;
 
int main() {
    S v(S());
 
    return S::i;
}

Q: What value will be returned?
A: 0.

Explanation: In fact none of available constructors will be called. S v(S()); will be treated as the definition of a function that returns a values of type S and gets one parameter of type S.

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
sho__ifting: