Is this forward declaration legal C++?

Discussion in 'C++' started by Joost Kraaijeveld, Jun 28, 2004.

  1. Hi all,

    Is this legal (including the namespace in the forward declarion):

    namespace NS
    {
    class NS:ForwardDeclaratedClass;
    };

    Other file:
    namespace NS
    {
    class ForwardDeclaratedClass
    {
    };
    };

    --
    Joost Kraaijeveld
    Askesis B.V.
    Molukkenstraat 14
    6524NB Nijmegen
    tel: 024-3888063 / 06-51855277
    fax: 024-3608416
    e-mail:
    web: www.askesis.nl
     
    Joost Kraaijeveld, Jun 28, 2004
    #1
    1. Advertising

  2. Joost Kraaijeveld wrote in news:a%UDc.24027$
    in comp.lang.c++:

    > Hi all,
    >
    > Is this legal (including the namespace in the forward declarion):
    >
    > namespace NS
    > {
    > class NS:ForwardDeclaratedClass;


    class ForwardDeclaratedClass;

    > };
    >
    > Other file:
    > namespace NS
    > {
    > class ForwardDeclaratedClass
    > {
    > };
    > };
    >


    Spurious 'NS:' aside yes.

    Rob.
    --
    http://www.victim-prime.dsl.pipex.com/
     
    Rob Williscroft, Jun 28, 2004
    #2
    1. Advertising

  3. Joost Kraaijeveld

    Sharad Kala Guest

    "Joost Kraaijeveld" <> wrote in message
    news:a%UDc.24027$...
    > Hi all,
    >
    > Is this legal (including the namespace in the forward declarion):


    Couple of things wrong with your code.

    > namespace NS
    > {
    > class NS:ForwardDeclaratedClass;

    class ForwardDeclaratedClass;

    > };

    No semicolon here
    >


    > Other file:
    > namespace NS
    > {
    > class ForwardDeclaratedClass
    > {
    > };


    > };

    No semicolon here too

    >

    Should be fine now.
     
    Sharad Kala, Jun 28, 2004
    #3
  4. Sharad Kala wrote in news: in comp.lang.c++:

    >
    > "Joost Kraaijeveld" <> wrote in message
    > news:a%UDc.24027$...
    >> Hi all,
    >>


    >
    > Couple of things wrong with your code.
    >
    >> namespace NS
    >> {


    >> };

    > No semicolon here


    Its a namespace not a class the semicolon isn't required.

    Rob.
    --
    http://www.victim-prime.dsl.pipex.com/
     
    Rob Williscroft, Jun 28, 2004
    #4
  5. Joost Kraaijeveld

    Sharad Kala Guest

    "Rob Williscroft" <> wrote in message
    news:Xns951695C6F7676ukcoREMOVEfreenetrtw@130.133.1.4...
    > Sharad Kala wrote in news: in comp.lang.c++:
    >
    > >> namespace NS
    > >> {

    >
    > >> };

    > > No semicolon here

    >
    > Its a namespace not a class the semicolon isn't required.


    And that's what I wrote (to drop the unnecessary semicolons), am I missing
    your point?
     
    Sharad Kala, Jun 28, 2004
    #5
  6. Sharad Kala wrote in news: in comp.lang.c++:

    >
    > "Rob Williscroft" <> wrote in message
    > news:Xns951695C6F7676ukcoREMOVEfreenetrtw@130.133.1.4...
    >> Sharad Kala wrote in news: in
    >> comp.lang.c++:
    >>
    >> >> namespace NS
    >> >> {

    >>
    >> >> };
    >> > No semicolon here

    >>
    >> Its a namespace not a class the semicolon isn't required.

    >
    > And that's what I wrote (to drop the unnecessary semicolons), am I
    > missing your point?
    >


    NO :). sorry for the noise.

    Rob.
    --
    http://www.victim-prime.dsl.pipex.com/
     
    Rob Williscroft, Jun 28, 2004
    #6
  7. Joost Kraaijeveld

    Howard Guest

    "Rob Williscroft" <> wrote in message
    news:Xns951699F954E92ukcoREMOVEfreenetrtw@130.133.1.4...
    > Sharad Kala wrote in news: in comp.lang.c++:
    >
    > >
    > > "Rob Williscroft" <> wrote in message
    > > news:Xns951695C6F7676ukcoREMOVEfreenetrtw@130.133.1.4...
    > >> Sharad Kala wrote in news: in
    > >> comp.lang.c++:
    > >>
    > >> >> namespace NS
    > >> >> {
    > >>
    > >> >> };
    > >> > No semicolon here
    > >>
    > >> Its a namespace not a class the semicolon isn't required.

    > >
    > > And that's what I wrote (to drop the unnecessary semicolons), am I
    > > missing your point?
    > >

    >
    > NO :). sorry for the noise.
    >


    Sharad, In case you're wondering why that mistake was made, you used the
    phrase "No semicolon here". That's an incomplete sentence in English, and
    it can be interpreted in two different ways. Either: "There is no semicolon
    here, but there should be, so you should add it.", or "No semicolon is
    required or desired here, so you should remove it." He apparently thought
    you meant the first, but you actually meant the second.

    -Howard
     
    Howard, Jun 28, 2004
    #7
  8. Joost Kraaijeveld

    Sharad Kala Guest

    "Howard" <> wrote in message
    news:WGYDc.154515$...
    >
    > "Rob Williscroft" <> wrote in message
    > news:Xns951699F954E92ukcoREMOVEfreenetrtw@130.133.1.4...

    [snip]
    > > NO :). sorry for the noise.
    > >

    >
    > Sharad, In case you're wondering why that mistake was made, you used the
    > phrase "No semicolon here". That's an incomplete sentence in English, and
    > it can be interpreted in two different ways. Either: "There is no

    semicolon
    > here, but there should be, so you should add it.", or "No semicolon is
    > required or desired here, so you should remove it." He apparently thought
    > you meant the first, but you actually meant the second.


    Howard,
    I know that the sentence was incomplete. But I think that the context in
    which I was talking was pretty clear. Interpreting it as "There is no
    semicolon here, but there should be, so you should add it." would mean that
    I have some problem in my eye sight which isn't the case actually. No
    offense meant.
     
    Sharad Kala, Jun 29, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. qazmlp
    Replies:
    1
    Views:
    605
    Jonathan Turkanis
    Feb 15, 2004
  2. Replies:
    3
    Views:
    452
  3. Carramba

    is this legal declaration/not correct output

    Carramba, May 16, 2007, in forum: C Programming
    Replies:
    12
    Views:
    571
    David Thompson
    Jul 1, 2007
  4. Replies:
    2
    Views:
    362
  5. Universe
    Replies:
    6
    Views:
    310
    Universe
    Mar 26, 2011
Loading...

Share This Page