0

that s what i learned since i saw in many examles programmers using a function main whithout any class
asking for any explication please :confused:

4
Contributors
4
Replies
5
Views
12 Years
Discussion Span
Last Post by Chainsaw
0

Not everything is an object. Only those things declared with 'class' or 'struct', or that are of a type that was declared with 'class' or 'struct'.

// NOT a class:
int DoSomething()
{
}

// IS a class:
class AClassThatDoesSomething
{
    int DoSomething();
};

int main()  // not a class
{
    DoSometing();  // not a class

    AClassThatDoesSomething ctds;
    ctds.DoSomething();  // IS a class member
}
0

that s what i learned since i saw in many examles programmers using a function main whithout any class
asking for any explication please :confused:

Object is a variable of type class.
Class is a type. Like structures and unions, class is a user defined data type.
Objects are variables of type Class. You can create n-number of objets(variables) of type class.
:cool:

0

An object is not just a C++ thing associated with a class.

object
region of data storage in the execution environment, the contents of which can represent values

So ints and pointers and arrays are objects too.

0

Well, you can call an 'int' an object, but in VC++ you can't say:

class Foo : public int
{
    Foo() {}
    virtual ~Foo() {}
};

So, it is not an object in the sense that you can't override it, inherit from it, make yourself a friend to it, and so on.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.