Re: A question about One Definition Rule

From: Gary (glabowitz_at_comcast.net)
Date: 11/30/03


Date: 29 Nov 2003 16:13:46 -0800

jeffplus@comcast.net (Jeff) wrote in message news:<a81f684.0311290636.2c26fbd9@posting.google.com>...
> > I just realized I might have broken the rule by defining the exception
> > classes in the header file. But my linker does NOT complain.
>
> The class definitions all have to be identical. As long as that's
> true (e.g. because they all come from the same included file), you're
> okay.

I'm glad the OP is now okay. But your answer threw me off.

Are you actually talking about a class definition, meaning the code of
the functions? Or do you mean a class declaration, which just
indicates what identifiers in the class refer to?

I have been teaching that the description of a class, giving its
contents by name, does not cause allocation of memory. I've called it
a declaration, only.
I'm aware that a declaration can also be a definiton (as in int x;
which declares x to be an int, and also allocates memory for an int
called x), but I'm under the impression that declaration of classes
does not also define unless code is contained in it. The actual
allocation of memory takes place when an object of the class type is
created.
These are such slippery terms, I'd like your input on this. Thanks.

--
Gary


Relevant Pages

  • Re: Newbie question
    ... >>> What I've done is declare a struct in a header file, ... >> Declaring structs, typedefs, function prototypes etc yes, defining ... >the header file and not again referenced in the code. ... >the header file in each code file is a duplicate declaration, ...
    (comp.lang.c)
  • Re: Newbie question
    ... >> What I've done is declare a struct in a header file, ... > Declaring structs, typedefs, function prototypes etc yes, defining ... the header file and not again referenced in the code. ... the header file in each code file is a duplicate declaration, ...
    (comp.lang.c)
  • Re: Functions in Lisp
    ... There is no "forward declaration" in Lisp, but you could fake it by ... defining an empty function, then defining the function which calls it, ... (defun recursive (x) ... "A call within a file to a named function that is defined in the same file refers to that function, unless that function has been declared notinline. ...
    (comp.lang.lisp)
  • Re: Requesting advice how to clean up C code for validating string represents integer
    ... % diff CookTop.html* ... < you will be defining later in the file. ... < fuction before you defie it, for example if you have two functions that ... < You write just a declaration for any function that needs to be called before ...
    (comp.lang.c)
  • Re: vc++ different basic types
    ... You have two header files that are defining values in different ways. ... The 3 source code files related to the above error is the following ... the open source project need the follow library ...
    (microsoft.public.vc.mfc)