class definitions

Discussion in 'C++' started by aliboyaci@gmail.com, Jul 18, 2006.

  1. Guest

    class a {
    int x(b * _b);
    };

    class b {
    int y(a * _a);
    };

    i want to make a definiton like that but i have errors. how can i solve
    this ?

    error : 4
    expected `;' before '(' token
    , Jul 18, 2006
    #1
    1. Advertising

  2. wrote:
    > class a {
    > int x(b * _b);
    > };
    >
    > class b {
    > int y(a * _a);
    > };
    >
    > i want to make a definiton like that but i have errors. how can i
    > solve this ?
    >
    > error : 4
    > expected `;' before '(' token


    Look up "forward declaration" in the FAQ. And next time read the
    FFAQ before posting, please.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Jul 18, 2006
    #2
    1. Advertising

  3. osmium Guest

    <> wrote:

    > class a {
    > int x(b * _b);


    What do you *want* to have happen here? Is '*' meant to be the multiply
    operator? b is (will be) a class, and classes have no value - only objects
    have values. And what is "_b" supposed to represent?

    > };
    >
    > class b {
    > int y(a * _a);
    > };
    >
    > i want to make a definiton like that but i have errors. how can i solve
    > this ?
    >
    > error : 4
    > expected `;' before '(' token
    >
    osmium, Jul 18, 2006
    #3
  4. osmium wrote:
    > <> wrote:
    >
    >> class a {
    >> int x(b * _b);

    >
    > What do you *want* to have happen here? Is '*' meant to be the
    > multiply operator? b is (will be) a class, and classes have no value
    > - only objects have values. And what is "_b" supposed to represent?


    Uh... It's a declaration of a funciton 'x' that takes a pointer to 'b'
    and returns an 'int'...

    > [...]


    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Jul 18, 2006
    #4
  5. osmium Guest

    "osmium" writes:

    > <> wrote:
    >
    >> class a {
    >> int x(b * _b);

    >
    > What do you *want* to have happen here? Is '*' meant to be the multiply
    > operator? b is (will be) a class, and classes have no value - only
    > objects have values. And what is "_b" supposed to represent?


    OK, I seen now what you wanted, and have already received an answer to your
    question, I saw the leading underscore as a kind of "magic incantation" and
    got sidetracked. Sorry about that.
    osmium, Jul 18, 2006
    #5
  6. ali Guest

    thanx alot Victor

    next time i will first read to faq :)
    as Victor said

    forward declaration :

    ------a.h-------
    class b;
    class a {
    int x(b * _b);
    };
    ------a.h-------

    ------b.h-------
    class a;
    class b {
    int x(a * _a);
    };
    ------b.h-------
    ali, Jul 18, 2006
    #6
  7. Mark P Guest

    ali wrote:
    > thanx alot Victor
    >
    > next time i will first read to faq :)
    > as Victor said
    >
    > forward declaration :
    >
    > ------a.h-------
    > class b;
    > class a {
    > int x(b * _b);
    > };
    > ------a.h-------
    >
    > ------b.h-------
    > class a;
    > class b {
    > int x(a * _a);
    > };
    > ------b.h-------
    >


    Just some suggestions...

    I think your function declarations would be more readable if the * were
    put immediately adjacent to the typename, e.g.:

    int x(b* _b);

    Additionally, I find that type names and variable names that differ only
    be a punctuation symbol are confusing to look at.

    And finally, user-defined names should not begin with an underscore as
    these are reserved for the implementation.
    Mark P, Jul 19, 2006
    #7
    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. E11
    Replies:
    1
    Views:
    4,711
    Thomas Weidenfeller
    Oct 12, 2005
  2. John Ericson
    Replies:
    0
    Views:
    419
    John Ericson
    Jul 19, 2003
  3. Mark
    Replies:
    0
    Views:
    434
  4. John Dibling
    Replies:
    0
    Views:
    405
    John Dibling
    Jul 19, 2003
  5. Rainer Weikusat
    Replies:
    1
    Views:
    203
    Rainer Weikusat
    Mar 8, 2013
Loading...

Share This Page