What types in C++ can be instantiated?
I know that the following each directly create a single instance of Foo
:
Foo bar;
Foo *bizz = new Foo();
However, what about with built-in types? Does the following create two instances of int
, or is instance the wrong word to use and memory is just being allocated?
int bar2;
int *bizz2 = new int;
What about pointers? Did the above example create an int *
instance, or just allocate memory for an int *
?
Would using literals like 42
or 3.14
create an instance as well?
I've seen the argument that if you cannot subclass a type, it is not a class, and if it is not a class, it cannot be instantiated. Is this true?