Urgent:Is int an object

K

krish

What is int primitive type.

Are primitive types like int , char , float are object. This is
question asked to me? Can any one help me?

Regards
Krish.
 
J

Jonathan Mcdougall

What is int primitive type.
Are primitive types like int , char , float are object. This is
question asked to me? Can any one help me?

They are definitively not objects, nor really classes. They are
primitive types, that`s it.

The only thing which makes them look like classes is the
constructor-like call :

int i = int();

which initializes 'i' to 0. This case was meant for simplifying
templates.

Variables having, for example, type 'int', are usually referred to as
'variables', not objects, but it does not hurt calling them like that
I suppose.


Jonathan
 
J

John Harrison

krish said:
What is int primitive type.

Are primitive types like int , char , float are object. This is
question asked to me? Can any one help me?

Regards
Krish.

What is the definition of object? You can define object so that an int is an
object, you can define object so that int is not an object. So your question
is very hard to answer unless you explain what you understand by the term
'object'.

john
 
J

Jim Fischer

Rolf said:
Jonathan Mcdougall wrote:




In C++ standard terminology (which is what matters here), everything
that occupies storage is an object.

<AR nit>
.... except for functions, of course. IOW, the code for a given function
occupies storage; but according to the C++ object model, that code
(i.e., that function) is not considered an object.
</AR nit>
 
D

David White

krish said:
What is int primitive type.

Are primitive types like int , char , float are object. This is
question asked to me? Can any one help me?

Types are not objects, so int, char etc. are not objects. User-defined
classes are also types and are not objects. You get an object when you
create an instance of a type, so an int is an object, a char is an object,
etc.

DW
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,137
Messages
2,570,800
Members
47,348
Latest member
Mikientp

Latest Threads

Top