an object can, and usually does, have other objects inside it.
a c++ std::string is an object. Just because string is a class in the standard language libraries does not change that :)
more specific to your code:
"Fluffy" is a string literal. Actually its a const char*, or a "C language string literal" if you want to get really picky about it.
dogName is a string object, created from copying the literal into the object.
Can all variables then be called objects
No, an integer is NOT an object. It could have been, but the so-called 'methods' you see (eg operator +, assignment, etc) are actually CPU hardware. Making an integer an object is a massive performance hit, see pure python language.
^^^ this is NOT obvious. One way to see it is to do this in an IDE that lists members (like visual studio).
string s;
s. <-- typing that . will bring up a list of class stuff.
int x;
x. <--- will NOT bring up anything.
Is m_pName the object <- IT IS "an" Object, one of several string objects in your code.
, the memory address that points to "Kato" or is "Kato" the object....which clearly IS a string literal? Probably the former?
Ignoring the c++ optimizer for a moment, as it can play tricks on you, for now assume that the string literal KATO is copied into the string object, into a new memory location that is part of that object.
So the object m_pName has a COPY of the data from the KATO literal.
Can dogName in main be called an object?
Yes, it is one.
Is vetName in Dog class an object?
Yes.
When you create an instance of a class, it is an object |
Stand by this. The trouble is simply spotting the class with built in language tools.
It may be easier to list the things that are not classes...
all pointers, any kind of int (includes char), any kind of float, (however complex numbers are objects!) literals that are not cast or forced into a class ("foo"s is a string object, that s casts it into one), enums (there is an enum class, it is different), things like this. You will get a feel for it quickly as you learn. Even cout is an object.