English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

can the size of class and object be different or can two objects of same class have different size.....plzz give some link along with ur explanation ?

2006-10-18 21:14:53 · 5 answers · asked by ultimate_spinz 3 in Computers & Internet Programming & Design

5 answers

People who said that class doesn't have size are wrong. It does.
The class is the definition of the type. The more properties and method it has, the bigger the size.
Objects of the class, have size too. Their sizes have little to do with the size of the class.
Two objects of the same class always have the same size. You can store references to other objects in those objects, that have different sizes (for example, an object could have a string property in it, and that string could be of different length in different objects), but those don't count towards the size of the object itself.
The size of the object is completely defined by it's type. In languages, that trust you enough to let you manage your own memory - like C or C++ - there is a compiler macro sizeof() that, given the type of the object, tells you its size in bytes.

If by "two objects of the same class" you meant the same base class, but different types, then sure, they can have different sizes. And they are not really "of the same class"

As for the link... I am not sure what link you are asking for...
Perhaps, this will do: http://www.google.com

2006-10-19 01:48:02 · answer #1 · answered by n0body 4 · 1 0

class does not have size. It comes into existance when you create an object of it.
object can be of different sizes depending upon the data that it contains.

2006-10-18 21:21:20 · answer #2 · answered by Anonymous · 0 0

The class is the definition of the object - do not get the two confused. Read up on inheritance, as I think this is possibly what you are thinking of.

If you want links, search Google.

Rawlyn.

2006-10-18 21:22:07 · answer #3 · answered by Anonymous · 0 0

two objects derived from the same base class are allowed to have different properties and methods. hope this helps answer your question, good luck :)

2006-10-18 22:15:49 · answer #4 · answered by Adeel I 3 · 0 0

as a results of fact C++ is only too useful for this is own sake. With C++, you're able to be able to make a application it somewhat is merchandise oriented, despite if it is likewise possible to make non merchandise oriented application in C++, like procedural. possibly this is the case that makes it no longer seen organic merchandise oriented, when you consider which you're actually not compelled to create merchandise oriented application. you're able to be able to additionally blend up merchandise oriented and procedural in C++.

2016-12-08 17:16:18 · answer #5 · answered by ? 4 · 0 0

fedest.com, questions and answers