Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > technical correctness

Reply
Thread Tools

technical correctness

 
 
Paul
Guest
Posts: n/a
 
      01-06-2011

"Ian Collins" <ian-> wrote in message
news:...
> On 01/ 6/11 11:35 AM, PaulR wrote:
>> On Jan 5, 8:37 pm, Paavo Helde<myfirstn...@osa.pri.ee> wrote:
>>> "Paul"<pchris...@yahoo.co.uk> wrote
>>> innews:7f3Vo.66960$2:
>>>
>>>> More to the point a class is the definition of an object.
>>>
>>> An example of a class:
>>>
>>> class A {
>>> int x;
>>> int y;
>>>
>>> };
>>>
>>> There is no object of type A defined here by this class. The objects, if
>>> any, are defined later in other parts of the program, e.g.
>>>
>>> A a;
>>>
>>> This line is the definition of an object a (by the C++ standard). It is
>>> a
>>> single line which contains the name of the class. However, this line
>>> does
>>> not "contain" the class A, it only refers to the class A. So it does not
>>> make any sense to say that "a class is the definition of an object".
>>> Besides, there may be many objects of the same class, one does not
>>> create
>>> a new class for each new object.

>>
>>
>> THe C++ standards states the following:
>>
>> "2 A class is considered a completely-defined object type (3.9) (or
>> complete type) at the closing } of the
>> class-specifier. "

>
> The important word there is 'type'.
>
> A is a type, a is an instance of that type.
>

So it follows that, as 'a' is of type 'A', 'a' is defined in class A.
There is only one definition for all A's.
Are you suggesting that each instance has a seperate definition?

 
Reply With Quote
 
 
 
 
Ulrich Eckhardt
Guest
Posts: n/a
 
      01-06-2011
Paul wrote:
> "Ulrich Eckhardt" <> wrote in message
> news:...
>> [...] you talk about instances of an object, but that
>> term itself doesn't make sense. An object is an instance of a type. You
>> can not have instances of an object. You can have multiple instances of
>> the same type as an object, but that's not what you said.
>>

>
> So what happens if you copy an object?
> You create a new instance of that object.


No, you create a new instance from that object. One started its life based
on the other. They are not two instances of the same object, as that very
term makes no sense. Get on the web and try to get a thorough
understanding of the difference between "identity" and "equality".

> What part of that do you find difficult to understand?


I find you hard to understand, because several things have been explained
to you multiple times and you still don't get them. Even worse, you call
people idiots and bullies just because they tend to get fed up with you,
but you obviously don't spend much time understanding other people's point
in the first place.

 
Reply With Quote
 
 
 
 
Joshua Maurice
Guest
Posts: n/a
 
      01-06-2011
On Jan 5, 5:56*pm, "Paul" <pchris...@yahoo.co.uk> wrote:
> So it follows that, as 'a' is of type 'A', 'a' is defined in class A.
> There is only one definition for all A's.
> Are you suggesting that each instance has a seperate definition?


For fear of repeating some horrible behavior I recently did in C, IMHO
this is how it goes.

A declaration introduces a name into scope and gives a particular
meaning to that name.

A definition is some "thing" which gives a particular meaning to some
entity which is not a name. Such things include classes, types,
functions, objects, and so on. Usually there is exactly one definition
of any particular "thing" in any one program, aka the One Definition
Rule.

A definition is usually a declaration - a definition usually brings
into scope a new name with a particular meaning.
class Foo {};
The above is a declaration of the name Foo. It is also a definition of
the type with name Foo. It is a definition of a type, of a class, of a
class type, of an object type, of a user-defined type, and so on.
Usually we use shorthand and say it's the definition of Foo.

class Foo;
The above is a declaration of the name Foo. It declares that the name
Foo refers to a class type. It is not a definition of a type.

extern Foo bar;
The above is a declaration of the name bar. It declares that the name
bar refers to an object of type Foo. It is not a definition of a type.
It is not a definition of an object.

Foo baz = Foo();
The above is a declaration of the name baz. It declares that the name
baz refers to an object of type Foo. It is also a definition of an
object with the name baz. Usually we use shorthand and say it's the
definition of baz. This is not a declaration nor definition of the
type Foo.

Questions?
 
Reply With Quote
 
James Kanze
Guest
Posts: n/a
 
      01-06-2011
On Jan 5, 4:05 pm, "Paul" <pchris...@yahoo.co.uk> wrote:
> "James Kanze" <james.ka...@gmail.com> wrote in message


[...]
> > More to the point, C++ very distinctly distinguishes between
> > "object" and "class", with an object being an instance of
> > a class. Formally, it is the class which has members, not the
> > object, although it makes sense in less formal speech to speak
> > of the members of an object when one is referring to the members
> > of the class which have a separate instance in each object (e.g.
> > the non-static data members).


> More to the point a class is the definition of an object.
> Classes and objects are not completely different entities as you suggest.


"Class" and "object" are two different words, with very
different meanings. Object is a runtime concept: objects have
lifetime. And an object may be of any type, not just a class
type. Class is a compile time concept: a class has scope, for
example, which an object doesn't, but it doesn't have lifetime.
The two things are quite different.

--
James Kanze
 
Reply With Quote
 
Garrett Hartshaw
Guest
Posts: n/a
 
      01-06-2011
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/05/2011 08:01 PM, Keith Thompson wrote:
> Garrett Hartshaw <> writes:
> [...]
>> When you copy an object, you get a new instance of the class that that
>> object was based on with that same values for all of the members. As a
>> class is defined by the C++ standard to be a region of storage, it is
>> nonsensical to say that you have a new instance of that region of
>> storage. What you have is a different region of storage that happens to
>> be storing the same thing.

>
> Correction: an *object*, not a class, is defined to be a region of
> storage. (I'm sure it was just a typo.)
>
> Note also that the type of an object needn't be a class. For example:
>
> int x;
>
> creates an object (a region of storage than can hold values of type int).
>

Yes that was a typo, and I was trying to narrow it down to objects with
a type defined by a class, not that I really expect that to help.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJNJhRzAAoJEO0SzzQOdchNWlQQAI1jKDKele 55KccRO3bp+vXC
0sxixa9cmvTpox35z9XXpgJxgX3IAK9SC7eHDvNnChR48ITd5J fXTUK9Q+ckSNQK
wbf7DzZPHyex0jLbE+hEpfcg9yjs+RI9TaoITs89t++7iRzcc8 Bw0ztuy8Kjl7rB
X9i6QkPDCsMhp4yTHMBYqUJl9PFXI4OQjL9sDqLiM1RIGOVYNa 8+RKeQQi5OLW70
Qt3dm4Jfv+Su9xbcyCCrXzp/HQK5jSwqOZb2RYlbBuTC2hsMBCllIboqqf/hKQwo
kxVSddornQfhiS35NA7LZZ6/SONlc+z7tw0bBMPyAekyJNFPC5dTPGSHOeeNtazK
/oALIxvhZuZBxmc6QlIsn3eHtNoEMlQ1sUS2WGLx2OijpFSwyxD E2JIOqjd+8m16
CqYHJA3FZbyoJb1OZea/lTyzOHcJiqssBJJ+iFE9F0KCGfROtaRfcA2k1x/dm0BL
9xMnXhC/ASXgBjZmNe/Olgw1XOY4R4FCp+3ynFNShFtk/fo9bUrCK2UPTDsqRCCV
hjAyCSYvnFMiEe+s4opXOUt2LDUPNVJIIOQlL+zQMtTIGZb2Uv UpLXBucfnarSjf
2bGBErqJi/kKquYlLdoufVEp8sPgIiJj9X8R0KttnTTAl0HHsi61LIyH2orD G+XM
IoNnzEDvAZeb/1qmbA18
=Vd1f
-----END PGP SIGNATURE-----
 
Reply With Quote
 
Ulrich Eckhardt
Guest
Posts: n/a
 
      01-06-2011
Paul wrote:
> A class is an object type as the C++ standards clearly state:


Yes, a class is a type, just like an enumeration. A type is not an object.
An object type is also not an object, but a type. Instantiating it will
yield an object.

Simple thing, at least for those willing to understand.

 
Reply With Quote
 
Niklas Holsti
Guest
Posts: n/a
 
      01-08-2011
Paul wrote:
> A non-static
> member function declared within an objects class is exclusivelly related
> to that object and no other object.


So, assume a class C, a non-static member function foo() defined within
C, and two different objects x and y, both instances of class C.

By your reasoning, since foo() is defined within the class of object x,
foo() is exclusively related to x and to no other object.

By the same reasoning, since C is also the class of object y, foo() is
also exclusively related to y and to no other object.

That is a contradiction, since x and y are different objects. Thus your
statement above is wrong.

--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      01-08-2011

"Niklas Holsti" <> wrote in message
news:...
> Paul wrote:
>> A non-static member function declared within an objects class is
>> exclusivelly related to that object and no other object.

>
> So, assume a class C, a non-static member function foo() defined within C,
> and two different objects x and y, both instances of class C.
>
> By your reasoning, since foo() is defined within the class of object x,
> foo() is exclusively related to x and to no other object.


No foo() is not neccessarily defined within the class, it is declared in the
class.
The class defines the type-C. That is, the class defines that all objects of
type-C will have a member function foo();
Note this is not the same as saying the member function foo() is deifned in
the class.


>
> By the same reasoning, since C is also the class of object y, foo() is
> also exclusively related to y and to no other object.
>
>
> That is a contradiction, since x and y are different objects. Thus your
> statement above is wrong.



I dont even know what you are trying to say I am wrong about here and I dont
really care much anymore but.....
I think you will find it's obviously you thats wrong .


>
> --
> Niklas Holsti
> Tidorum Ltd
> niklas holsti tidorum fi
> . @ .
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
technical correctness 2 PaulR C++ 19 01-07-2011 09:41 PM
stl list, const correctness Jim Strathmeyer C++ 2 03-20-2005 12:37 AM
A technical question from a non-technical person. Any suggestions appreciated. Graham Cross VOIP 2 01-27-2005 09:13 PM
convert the content of a string to an expression to check its correctness spiros C++ 7 07-20-2004 09:41 PM
Correctness of code for box with header Ryan Stewart HTML 9 03-07-2004 07:53 PM



Advertisments