Why is this constructor not "exectued"?

In the following I define an object "foo" by just writing "Foo foo();" in the "root of the file" (what I mean is: not inside a function). Is there a nice word/term for this kind of initialization, as opposed to initializing an object within a function?

It seems like the constructor is just never called. Is it ever called then? Or should I do something more to initialize the "foo" object?

As the code demonstrates, the constructor IS called when initializing objects of class Foo inside a function.

int count = 0;

class Foo
   Foo ();

Foo::Foo() {
  count ++;

Foo foo(); // initialize one

void setup() {

// the loop routine runs over and over again forever:
void loop() {

Please correct me if I am using the terms initialization/declaration/construction wrong.


Your initialization is wrong.


Foo foo; // really initialize one

Like he said. When you say:Foo foo(); you are declaring a function named 'foo' that returns a value of type 'Foo'. It's the parentheses that make it a function declaration.

Whooaaa,,, aahhhh,,, not sure how to react. Thanks a lot :)