Re: Newbie static class member question [C++]
From: Francis Glassborow (francis_at_robinton.demon.co.uk)
Date: 04/17/04
- Next message: anders: "sprintf expression [C]"
- Previous message: A. Name: "Re: Parsing String from file"
- In reply to: Leor Zolman: "Re: Newbie static class member question [C++]"
- Next in thread: Leor Zolman: "Re: Newbie static class member question [C++]"
- Reply: Leor Zolman: "Re: Newbie static class member question [C++]"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 17 Apr 2004 07:01:17 +0100
In message <sf8180p8upsud6sb44rb0bv5ckdetcfv8h@4ax.com>, Leor Zolman
<leor@bdsoft.com> writes
>Actually it's "class definition". In C++, a class declaration looks like
>this:
>
> class Foo;
>
>and allows subsequent declarations to refer to Foo in certain contexts
>(such as defining a pointer or reference to Foo) but not others (such as
>defining an object of type Foo). The above results in Foo being an
>"incomplete type", to be completed after the compiler sees the class
>definition. I know, the terms are infuriatingly inconsistent and
>overloaded. That's life with C++.
Well there are a lot of little inconsistencies in C++ but I do not think
this is one of them. A declaration introduces a name with information
about how it can be used. That information is type information so:
int i;
there is a name 'i' which designates an int
int foo(double);
there is a name 'foo' which designates a function which uses a single
value of type double and returns a value of int type.
class mytype;
there is a name 'mytype' that designates a user defined class type.
In some contexts a declaration is also a definition. A definition
provides a point where all the information necessary to use an entity
has been provided.
The thing that confuses some people (and most authors:() is that a class
definition consists of the declarations of its members. If you think
about it that is all that is needed to use a class object. However those
declarations just introduce the names of the parts of the class. At that
inner level we have names that still need definitions. We conventionally
call the set of definitons of the members of a class 'its
implementation. This has got generalised into optionally referring to a
function definition as its 'implementation'owever C++ is always clear as
to whether a statement is just a declaration or is also a definition. C
isn't because it has something called a 'tentative definition' which
effectively means that it is a definition until something better comes
along. C++ does not allow that, something is either unambiguously a
definition or it is just a declaration.
-- Francis Glassborow ACCU Author of 'You Can Do It!' see http://www.spellen.org/youcandoit For project ideas and contributions: http://www.spellen.org/youcandoit/projects
- Next message: anders: "sprintf expression [C]"
- Previous message: A. Name: "Re: Parsing String from file"
- In reply to: Leor Zolman: "Re: Newbie static class member question [C++]"
- Next in thread: Leor Zolman: "Re: Newbie static class member question [C++]"
- Reply: Leor Zolman: "Re: Newbie static class member question [C++]"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|