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.
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
         o      O  o                     `OooOOo.  
OooOOo O o O o `o
o o O o O O
O oO o o .O
ooOOo. Oo O o .oOoO' .oOo. OOooOO'
O o o OoO O o O o o o
o O O o O o O o O O O
`OooO' O o O o `OoOo oOoO' O o
`o o'
Enter the code depicted in ASCII art style.