Question

Sample Code
class Foo { int i; public: Foo(int x) : i(x) { } };

Referring to the sample code above, which one of the following lines of code is syntactically correct C++?

Choice 1: Foo &f = new Foo(1);
Choice 2: Foo *f = new Foo;
Choice 3: Foo *af = new Foo[10];
Choice 4: const Foo &af = Foo(1);
Choice 5: int i = Foo::i;
We're not a homework service.

Besides... you could always try compiling them to see.
The only correct line is line 4.
Topic archived. No new replies allowed.