 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Dylan Guest
|
Posted: Mon Dec 20, 2004 9:20 am Post subject: What's the difference between an object and a type? |
|
|
thanks
|
|
| Back to top |
|
 |
Jacques Labuschagne Guest
|
Posted: Mon Dec 20, 2004 10:00 am Post subject: Re: What's the difference between an object and a type? |
|
|
Dylan wrote:
An object is an instance of a type.
Jacques.
|
|
| Back to top |
|
 |
Jonathan Turkanis Guest
|
Posted: Mon Dec 20, 2004 10:41 am Post subject: Re: What's the difference between an object and a type? |
|
|
It's like the difference between a boxer and a weight class, or an employee and
a job description.
Jonathan
|
|
| Back to top |
|
 |
Rafal 'Raf256' Maj Guest
|
Posted: Mon Dec 20, 2004 12:45 pm Post subject: Re: What's the difference between an object and a type? |
|
|
[email]spaldeen (AT) ontheball (DOT) com[/email] news:396ds0di29m3m8f64uo50bms7is3nn5vjh (AT) 4ax (DOT) com
The same as between "a humen" and "the Dylan".
--
~~~~=~~~~l_;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_|___J ____, Pozdrawiam, moje www, C++, kontakt, itd.:
X-( ssn256 ) Rafal Maj Raf256 - http://www.raf256.com/me-news/
,"-------------" (strona w budowie)
|
|
| Back to top |
|
 |
Rafal 'Raf256' Maj Guest
|
Posted: Mon Dec 20, 2004 12:54 pm Post subject: Re: What's the difference between an object and a type? |
|
|
[email]spaldeen (AT) ontheball (DOT) com[/email] news:396ds0di29m3m8f64uo50bms7is3nn5vjh (AT) 4ax (DOT) com
| Quote: | thanks
The same as between "a humen" and "the Dylan".
|
typo... *human*
--
~~~~=~~~~l_;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_|___J ____, Pozdrawiam, moje www, C++, kontakt, itd.:
X-( ssn256 ) Rafal Maj Raf256 - http://www.raf256.com/me-news/
,"-------------" (strona w budowie)
|
|
| Back to top |
|
 |
Jon Bell Guest
|
Posted: Mon Dec 20, 2004 1:59 pm Post subject: Re: What's the difference between an object and a type? |
|
|
In article <396ds0di29m3m8f64uo50bms7is3nn5vjh (AT) 4ax (DOT) com>,
Dylan <spaldeen (AT) ontheball (DOT) com> wrote:
object :: type == cookie :: cookie-cutter
--
Jon Bell <jtbellm4h (AT) presby (DOT) edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
|
|
| Back to top |
|
 |
Dave O'Hearn Guest
|
Posted: Mon Dec 20, 2004 3:02 pm Post subject: Re: What's the difference between an object and a type? |
|
|
What's the difference between "int" and "5"?
The question is rather vague. I don't know if it has an answer.
Philosophers have debated this stuff for thousands of years and show no
sign of stopping soon.
When inheritence comes in, it is important not to confuse the different
relationships. The type-instance relationship is not the same as the
base-derived relationship. Sometimes people will get sloppy and use the
phrase "is a" to describe all these relationships, like 'file' is an
fstream, fstream is an ifstream, etc. They are two different things.
--
Dave O'Hearn
|
|
| Back to top |
|
 |
Howard Guest
|
Posted: Mon Dec 20, 2004 4:08 pm Post subject: Re: What's the difference between an object and a type? |
|
|
"Dave O'Hearn" <daveoh77 (AT) pobox (DOT) com> wrote
| Quote: | What's the difference between "int" and "5"?
The question is rather vague. I don't know if it has an answer.
Philosophers have debated this stuff for thousands of years and show no
sign of stopping soon.
|
They have? I don't recall any such discussions. For example, "what's the
difference between 'human" and "Bob'?" One is a description/definition, the
other names a specific instance.
I see no confusion (or vagueness) here at all. An object is an instance of
a type. A type is a description (a declaration), which follows very cleary
defined rules in the C++ language. There are built-in types and
user-defined types. Since this question is asked in the C++ language
newsgoup, it seems pretty clear that these are the definitions asked for.
| Quote: |
When inheritence comes in, it is important not to confuse the different
relationships. The type-instance relationship is not the same as the
base-derived relationship. Sometimes people will get sloppy and use the
phrase "is a" to describe all these relationships, like 'file' is an
fstream, fstream is an ifstream, etc. They are two different things.
--
|
That's a rather confusing analogy. The "is a" relationship described public
inheritance, only. What this has to do with types and objects is, well,
nothing as far as I can see...?
No offense intended, Dave, but I think you're just going to confuse the
newbie here. Philosophy and C++ don't mix very well, in my opinion. :-)
-Howard
|
|
| Back to top |
|
 |
jeffc Guest
|
Posted: Mon Dec 20, 2004 4:35 pm Post subject: Re: What's the difference between an object and a type? |
|
|
"Howard" <alicebt (AT) hotmail (DOT) com> wrote
| Quote: |
When inheritence comes in, it is important not to confuse the different
relationships. The type-instance relationship is not the same as the
base-derived relationship. Sometimes people will get sloppy and use the
phrase "is a" to describe all these relationships, like 'file' is an
fstream, fstream is an ifstream, etc. They are two different things.
--
That's a rather confusing analogy. The "is a" relationship described public
inheritance, only. What this has to do with types and objects is, well,
nothing as far as I can see...?
|
Agreed. "Is a" makes sense in both contexts, even though it means 2 different
things.
|
|
| Back to top |
|
 |
Dave O'Hearn Guest
|
Posted: Mon Dec 20, 2004 4:42 pm Post subject: Re: What's the difference between an object and a type? |
|
|
Howard wrote:
| Quote: | I see no confusion (or vagueness) here at all. An object is an
instance of a type. A type is a description (a declaration), which
follows very cleary defined rules in the C++ language. There are
built-in types and user-defined types. Since this question is asked
in the C++ language newsgoup, it seems pretty clear that these are
the definitions asked for.
|
Exactly. I see no confusion either, but the OP is confused. How?
| Quote: | No offense intended, Dave, but I think you're just going to confuse
the newbie here. Philosophy and C++ don't mix very well, in my
opinion.
|
Almost. I was trying to show the OP that his question was confusing,
not to confuse the OP. The difference between a type and an object
should be obvious to everyone, no technical background required. If it
isn't obvious, there is probably some confusion in terms. But I can't
guess what that confusion is. It would help if he asked a more specific
question about objects and types. (Un)fortunately, if this is a
homework, he may not be able to.
--
Dave O'Hearn
|
|
| Back to top |
|
 |
Dave O'Hearn Guest
|
Posted: Mon Dec 20, 2004 5:09 pm Post subject: Re: What's the difference between an object and a type? |
|
|
jeffc wrote:
| Quote: | "Howard" <alicebt (AT) hotmail (DOT) com> wrote in message
That's a rather confusing analogy. The "is a" relationship
described public inheritance, only. What this has to do with
types and objects is, well, nothing as far as I can see...?
Agreed. "Is a" makes sense in both contexts, even though it
means 2 different things.
|
The FAQ has a whole section on confusions that arise from using "is a"
to describe the derived-base relationship.
http://www.parashift.com/c++-faq-lite/proper-inheritance.html
The FAQ recommends "is substituable for", and describes it in terms of
contracts.
--
Dave O'Hearn
|
|
| Back to top |
|
 |
Paavo Helde Guest
|
Posted: Mon Dec 20, 2004 6:54 pm Post subject: Re: What's the difference between an object and a type? |
|
|
An object takes up space in computer memory at runtime, a type does not.
hth
Paavo
|
|
| Back to top |
|
 |
Howard Guest
|
Posted: Mon Dec 20, 2004 7:42 pm Post subject: Re: What's the difference between an object and a type? |
|
|
"Paavo Helde" <paavo (AT) ebi (DOT) ee> wrote
| Quote: |
An object takes up space in computer memory at runtime, a type does not.
hth
Paavo
|
I don't think that's a good description, or even accurate. Computer memory
is doled out by the operating system, and may be largely out of the control
of the code as to exactly when and where it is allocated.
But, regardless of the memory model used, what about member functions and
static member data? Both of those exist independent of instances of a class
(i.e., objects), since they are shared by all instances. So simply
declaring a class or struct type may result in memory allocation for those
members, separate from any instanciated objects of that type.
-Howard
|
|
| Back to top |
|
 |
Jonathan Mcdougall Guest
|
Posted: Mon Dec 20, 2004 8:59 pm Post subject: Re: What's the difference between an object and a type? |
|
|
Howard wrote:
| Quote: | "Paavo Helde" <paavo (AT) ebi (DOT) ee> wrote in message
An object takes up space in computer memory at runtime, a type does not.
I don't think that's a good description, or even accurate. Computer memory
is doled out by the operating system, and may be largely out of the control
of the code as to exactly when and where it is allocated.
|
Agree.
| Quote: | But, regardless of the memory model used, what about member functions and
static member data? Both of those exist independent of instances of a class
(i.e., objects), since they are shared by all instances. So simply
declaring a class or struct type may result in memory allocation for those
members, separate from any instanciated objects of that type.
|
Who said that?
Jonathan
|
|
| Back to top |
|
 |
jeffc Guest
|
Posted: Mon Dec 20, 2004 9:03 pm Post subject: Re: What's the difference between an object and a type? |
|
|
"Dave O'Hearn" <daveoh77 (AT) pobox (DOT) com> wrote
| Quote: | jeffc wrote:
"Howard" <alicebt (AT) hotmail (DOT) com> wrote in message
That's a rather confusing analogy. The "is a" relationship
described public inheritance, only. What this has to do with
types and objects is, well, nothing as far as I can see...?
Agreed. "Is a" makes sense in both contexts, even though it
means 2 different things.
The FAQ has a whole section on confusions that arise from using "is a"
to describe the derived-base relationship.
http://www.parashift.com/c++-faq-lite/proper-inheritance.html
The FAQ recommends "is substituable for", and describes it in terms of
contracts.
|
I really see no reason for that, when it's perfectly natural in our regular
speech to discuss it as is. A dog is an animal. Fido is a dog. What could be
simpler? We don't go around saying "a dog is substitutable for an animal."
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|