1 or 2 objects

In the following snippet am I creating one or two objects? Can post entire code if necessary.

1
2
3
        Foo obj;
	Foo &ref = obj;
	Foo * ptr_obj = &obj;


You're only creating one object of type Foo.

Where else do you think you might be creating an object, apart from line 1?

(If one were being very pedantic, one could argue that an instance of any primitive type can be called an "object" in the most generic sense, and that a pointer is therefore an object. That's not the way most C++ developer would use the word, and I assume that's not the sense in which you're using it?)
Last edited on
Hi,

Ok, I got it, thx.
Topic archived. No new replies allowed.