How are objects and classes alike? I take it that objects are instances of a class and classes are data types which the user has defined. Am I correct?
What is the difference between an object and a class?
Collapse
X
-
Tags: None
-
Originally posted by scarecrow13I take it that objects are instances of a class and classes are data types which the user has defined. Am I correct? -
Classes an objects are not alike.
A class (or struct) is a declaration. It provides information to the compiler on how to a) create and object and b) how to use the object.
The object is the definition. The object technology folks like to use instance of a class but in C++ they are just variables. The compiler uses the class declaration to determine what data members are in the object and then follows specific rules to initialize those members.
Yes, all objects have a type which is the class (or struct) name.Comment
-
Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).Comment
-
Originally posted by scarecrow13How are objects and classes alike? I take it that objects are instances of a class and classes are data types which the user has defined. Am I correct?
type of class. Methods defined in that class are just 'implementation details' that
make that class/type usefull to work with.
kind regards,
JosComment
Comment