473,412 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

type, class, object

Hi,

I could understand the difference between class and object. However, I
could find out a good definiton of type. how to understand the
relaitonship between type, class, and object? Thanks!

Michael

Aug 2 '06 #1
7 1935
Michael wrote:
I could understand the difference between class and object. However, I
could find out a good definiton of type. how to understand the
relaitonship between type, class, and object? Thanks!
'class' is a user-defined type (UDT, a very common TLA in OOP). A type
is a "kind" of objects, definiting common traits of all *instances* of
that type ("objects"). Types in C++ are characterized by the name and
the *definition*. Types in C++ consist of built-in and user-defined.
The definition of a UDT contains *declarations*, which describe the
representation and the behaviour of the instances of the UDT. The
representation and the behaviour of built-in types is defined in the
Standard.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 2 '06 #2

Victor Bazarov wrote:
'class' is a user-defined type (UDT, a very common TLA in OOP). A type
is a "kind" of objects, definiting common traits of all *instances* of
that type ("objects"). Types in C++ are characterized by the name and
the *definition*. Types in C++ consist of built-in and user-defined.
The definition of a UDT contains *declarations*, which describe the
representation and the behaviour of the instances of the UDT. The
representation and the behaviour of built-in types is defined in the
Standard.
Could you please take an example for me to better understand it?

Aug 2 '06 #3

Victor Bazarov wrote:
Michael wrote:
I could understand the difference between class and object. However, I
could find out a good definiton of type. how to understand the
relaitonship between type, class, and object? Thanks!

'class' is a user-defined type (UDT, a very common TLA in OOP). A type
is a "kind" of objects, definiting common traits of all *instances* of
that type ("objects"). Types in C++ are characterized by the name and
the *definition*. Types in C++ consist of built-in and user-defined.
The definition of a UDT contains *declarations*, which describe the
representation and the behaviour of the instances of the UDT. The
representation and the behaviour of built-in types is defined in the
Standard.
I would think of type as "Class". Is thar right? There is no difference
to call "Class" or "Type".

Aug 2 '06 #4
Michael wrote:
Hi,

I could understand the difference between class and object. However, I
could find out a good definiton of type. how to understand the
relaitonship between type, class, and object? Thanks!

Michael
Well, in C++ : the types *include* the classes and objects are instances
of classes. Some types that are not classes :

C-like types : int, char, float
Function pointers types : int (*)(int,int)
Method pointers types : int (MyClass::*)(int,int)
Other pointers type : int*, MyClass*

Pierre
Aug 2 '06 #5
Michael wrote:
Victor Bazarov wrote:
>Michael wrote:
>>I could understand the difference between class and object.
However, I could find out a good definiton of type. how to
understand the relaitonship between type, class, and object? Thanks!

'class' is a user-defined type (UDT, a very common TLA in OOP). A
type is a "kind" of objects, definiting common traits of all
*instances* of that type ("objects"). Types in C++ are
characterized by the name and the *definition*. Types in C++
consist of built-in and user-defined. The definition of a UDT
contains *declarations*, which describe the representation and the
behaviour of the instances of the UDT. The representation and the
behaviour of built-in types is defined in the Standard.

I would think of type as "Class". Is thar right?
No, in C++ it's vice-versa. Did you actually read what I posted?

Types consist of built-in and user-defined. "class" is a user-defined
type. So class is a type. A 'type' is a wider concept than a 'class',
at least in C++.
There is no
difference to call "Class" or "Type".
In some circumstances there is. You can derive from a class, you
cannot, generally speaking, derive from a type.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 2 '06 #6

"Michael" <mi*******@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
>
Victor Bazarov wrote:
>Michael wrote:
I could understand the difference between class and object. However, I
could find out a good definiton of type. how to understand the
relaitonship between type, class, and object? Thanks!

'class' is a user-defined type (UDT, a very common TLA in OOP). A type
is a "kind" of objects, definiting common traits of all *instances* of
that type ("objects"). Types in C++ are characterized by the name and
the *definition*. Types in C++ consist of built-in and user-defined.
The definition of a UDT contains *declarations*, which describe the
representation and the behaviour of the instances of the UDT. The
representation and the behaviour of built-in types is defined in the
Standard.

I would think of type as "Class". Is thar right? There is no difference
to call "Class" or "Type".
Where do you get the word "Class" from? Are you referring to the keyword
"class", which denotes one kind of user-defined-type? (The other being the
keyword "struct".)

The concept of "type" in C++ means, basically, "what kind of thing is
this?". So, some examples of types are: int, char, and unsigned long.
These are built-in types, already defined in the language for you.

If you have a class definition like this:

class MyClass { /* member stuff here */ };

....then you have a user-defined type (or UDT), whose type is MyClass.

Likewise, the definition

struct MyStruct { /* member stuff here */ };

....defines a UDT, whose type is MyStruct.

(Sometimes in OOP, the terms "UDT" and "class" are used interchangeably, but
to me that can be confusing, since in C++ we also have UDTs which are
struct's, as I've shown.)

Given the above definitions,

MyClass aMyClassInstance;

....declares a variable called aMyClassInstance, whose type is MyClass, and

MyStruct aMyStructInstance;

....declares a variable called aMyStructInstance, whose type is MyStruct, and

-Howard


Aug 2 '06 #7
Howard wrote:
>
"Michael" <mi*******@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
I would think of type as "Class". Is thar right? There is no
difference to call "Class" or "Type".

Where do you get the word "Class" from? Are you referring to the
keyword "class", which denotes one kind of user-defined-type? (The
other being the keyword "struct".)
Poor ol' "union", forsaken again.


Brian
Aug 2 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Steve Brown | last post by:
Hello all, Is there a way to determine a variable's type at run-time? The reason I'm asking is that i have code that looks like this: template <class T> Object::Object(int TypeCode, T* data)...
100
by: E. Robert Tisdale | last post by:
What is an object? Where did this term come from? Does it have any relation to the objects in "object oriented programming"?
14
by: Matt | last post by:
I want to know if "int" is a primitive type, or an object? For example, the following two approaches yield the same result. > int t1 = int.Parse(TextBox2.Text); //method 1 > int t2 =...
3
by: Mike in Paradise | last post by:
I have an application that is being passed objects which could either be an instance or a Type in the case of a Static Class When you do the GetType on the object that was originally a Static...
0
by: Nashat Wanly | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaskdr/html/askgui06032003.asp Don't Lock Type Objects! Why Lock(typeof(ClassName)) or SyncLock GetType(ClassName) Is Bad Rico...
23
by: René Nordby | last post by:
Hi there, Is there anyone that knows how to do the following? I have a class A and a class B, that 100% inherits from class A (this means that I don't have other code in class B, than...
16
by: Dennis | last post by:
I have a class named "myclass" and an arraylist containing elements of type "MyClass". I want to get the value of a property of "MyClass" (a string type) for one of the arraylist elements. I...
11
by: JohnR | last post by:
I'm trying to find a way to create a variable of a given type at runtime where I won't know the type until it actually executes. For example, dim x as object = "hi" x is declared as an object...
5
by: JH | last post by:
Hi I found that a type/class are both a subclass and a instance of base type "object". It conflicts to my understanding that: 1.) a type/class object is created from class statement 2.) a...
21
by: Nikolaus Rath | last post by:
Hello, Can someone explain to me the difference between a type and a class? After reading http://www.cafepy.com/article/python_types_and_objects/ it seems to me that classes and types are...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.