What is the definition of "Object"

closed account (zybCM4Gy)
http://www.cplusplus.com/doc/tutorial/structures/

Regarding the new de-reference operator, the tutorial uses the phrase:

exclusively with pointers to objects that have members


Now. I'm pretty sure (not certain) that the new De-reference operator cannot be used with an array. Which means that there is some limitation to the word "Object".

Also the following sources confuse the hell out of me.

1. University of Illinois http://www.cs.uic.edu/~jbell/CourseNotes/C_Programming/OOP_CPlusPlus.html

Objects are specific instances of classes. E.g. objects are variables, classes are types.


2. Oracle http://docs.oracle.com/javase/tutorial/java/concepts/

An object is a software bundle of related state and behavior.


3. Code Project http://www.codeproject.com/Articles/22769/Introduction-to-Object-Oriented-Programming-Concep#Object

An object can be considered a "thing" that can perform a set of related activities.


4. Microsoft http://msdn.microsoft.com/en-us/library/dd460654.aspx#Classes
The terms class and object are sometimes used interchangeably, but in fact, classes describe the type of objects, while objects are usable instances of classes. So, the act of creating an object is called instantiation


So... if a struct isn't an object why do does the new de-reference item work with structs and if it *is* an object, then the majority of the above definitions have to be false in which case I don't have any definition of what an object is...

oh my head hurts.
a class/struct tells the compiler what an object is made up of. The object is just the variable name.
1
2
3
4
5
6
7
8
class CookieCutter
{
    int a; //4 bytes
    char c; 1 byte
}; //5 bytes


CookieCutter cookie; //cookie is an object that is 5bytes 




http://www.tutorialspoint.com/cplusplus/cpp_classes_objects.htm
Define C++ Objects:
A class provides the blueprints for objects, so basically an object is created from a class. We declare objects of a class with exactly the same sort of declaration that we declare variables of basic types. Following statements declare two objects of class Box:
1
2
Box Box1;          // Declare Box1 of type Box
Box Box2;          // Declare Box2 of type Box 

Both of the objects Box1 and Box2 will have their own copy of data members.


closed account (zybCM4Gy)
So an object is just a variable name that contains data.

So for example... (so that I understand this properly).

1
2
3
4
5
struct vegetable
{
     short int length = 0;
     short int mass = 0;
} carrot;


So carrot is the object here and not vegetable? I'm bearing in mind that structs aren't actually considered classes because they only store variables. Different types of variables admittedly, perhaps even structs. But there are no behaviours etc.

So...

1
2
3
int array[3] = {1 , 2, 3}
int *apple = &array[1];  // apple != object?


Structs are commonly used for POD (plain old data) but the only real difference between structs and classes is their default access; struct being public and class private.

Yes carrot is the object and not vegetable.

Basically a variable is an object.

There are 3 things to create an object:

1) blueprint (template)
2) data type
3) object name

1
2
3
4
5
6
7
8
9
10
//blueprint for creating an object
struct vegetable
{
     short int length = 0;
     short int mass = 0;
};

vegetable carrot;
//vegetable = data type
//carrot = object name 


Also

An object is an instantiation of a class. In terms of variables, a class would be the type, and an object would be the variable.

http://www.cplusplus.com/doc/tutorial/classes/

I think you should read that link.

closed account (zybCM4Gy)
I think they should explain this rubbish before teaching me about structs ._.;. Which is where I'm up to at the moment.

Thanks

Edit.

So...templates spawn objects too....oh brother.
Last edited on
When I say template I mean what is an object made up of (blueprint) otherwise how else would the compiler know how many bytes each object is made up of.
Topic archived. No new replies allowed.