This is the mail archive of the
docbook@lists.oasis-open.org
mailing list for the DocBook project.
Re: Prototypes of C++ methods
- To: docbook at lists dot oasis-open dot org
- Subject: Re: DOCBOOK: Prototypes of C++ methods
- From: Jan Ekholm <chakie at infa dot abo dot fi>
- Date: Wed, 22 Mar 2000 14:59:06 +0200 (EET)
- Reply-To: docbook at lists dot oasis-open dot org
On Wed, 22 Mar 2000, Norman Walsh wrote:
>
>| Packet * receive (const bool Block = false);
>|
>| But how do I get an extra 'const' in there? Like this?
>|
>| Packet * receive (const bool Block = false) const;
>|
>| I haven't found any way of doing it. Can it be done, or have I just
>| misunderstood something? I hope this kind of question is relevant for this
>| list, otherwise I apologize.
>
>It's definitely relevant. The new ClassSynopsis stuff in DocBook
>V4.0 is intended to provide better support for object oriented
>languages, but this appears to just be a function (as opposed to
>a method) with additional modifiers. I don't think we've covered
>that case yet.
It is a method, but I explain in the paragraphs before the method
prototype what is all about. Like this:
Bla, bla, blaa, we have the very nice class Foo with the following handy
method:
Packet * receive (const bool Block = false) const;
>Refresh my C++ :-), what does the trailing const mean in this case?
it tells the compiler/you that the method in question will not alter the
used object in any way, or return something that could be used to do it.
It is a good habit to clearly state with 'const' which methods of a class
fill that property.
As an other question regarding <funcsynopsis>, is it possible to control
the width of the generated funtion prototype somehow? I have a lot of
those prototypes, and many have at least three parameters, which means
that the print output is split on two lines, which reduces readability. I
use <programlisting> a lot too, andit has a 'width' attribute which lets
me specify the number of characters on one line. It would be nice if that
could be done with <funcsynopsis> too.
Regards, Chakie
---------------------+------------------------------------------------------
Jan 'Chakie' Ekholm | CS at Åbo Akademi University, Turku, Finland
Linux Inside | I'm the blue screen of death, no-one hears you scream