typedefs and namespaces

Discussion in 'C++' started by alariq, Jan 29, 2010.

  1. alariq

    alariq Guest

    Hello, All
    can anyone help me with my problem. Here is it
    I have one file: a.h
    --- a.h ---
    #pragma once
    class Value; // forward declaration

    namespace a {
    // probably i would like to create Joint class as separate but now
    i want to use Value class
    typedef ::Value Joint;
    class A_Class {
    };

    class C {
    public:
    //...
    Joint* j;
    };
    } // end of namespace

    and another class b.h, which includes a.h
    --- b.h ---
    #pragma once
    #include "a.h"

    class Value {
    a::A_Class* pclass;
    public:
    static Value* makeStuff() { return new Value; }
    }

    and a main class
    --- main.cpp ---
    #include "b.h"
    #include "a.h" // not really needed

    int main(int argc, char** argv)
    {

    a::C var2;
    var2.j = new a::Joint::makeStuff(); // error C2061: syntax error :
    identifier 'makeStuff'
    return 0;
    }

    I canot get why i have an error, becuase a::Joint is the same as
    Value. It is ok if i do not use the function but fails if i do.

    Thanks in advance.
     
    alariq, Jan 29, 2010
    #1
    1. Advertising

  2. alariq wrote:
    > Hello, All
    > can anyone help me with my problem. Here is it
    > [...]
    >
    > and a main class
    > --- main.cpp ---
    > #include "b.h"
    > #include "a.h" // not really needed
    >
    > int main(int argc, char** argv)
    > {
    >
    > a::C var2;
    > var2.j = new a::Joint::makeStuff(); // error C2061: syntax error :
    > identifier 'makeStuff'


    The compiler expects a *type* after 'new'. For example,

    var2.j = new a::Joint;

    What is it you're trying to accomplish here?

    > return 0;
    > }
    >
    > I canot get why i have an error, becuase a::Joint is the same as
    > Value. It is ok if i do not use the function but fails if i do.


    Use the function to do *what*?

    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, Jan 29, 2010
    #2
    1. Advertising

  3. alariq

    alariq Guest

    On Jan 29, 6:45 pm, Victor Bazarov <> wrote:
    >
    > Use the function to do *what*?


    Blind I am! Thank you Viktor. I guess, it just was not my hard day
    today...
     
    alariq, Jan 29, 2010
    #3
    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. emerth
    Replies:
    3
    Views:
    379
    emerth
    Aug 8, 2003
  2. dwrayment

    Templates and Typedefs

    dwrayment, Aug 12, 2003, in forum: C++
    Replies:
    6
    Views:
    401
    Sam Holden
    Aug 14, 2003
  3. Dylan
    Replies:
    7
    Views:
    569
    Dylan
    Jul 7, 2004
  4. Simon Elliott

    Forward declaration and typedefs

    Simon Elliott, Jan 7, 2005, in forum: C++
    Replies:
    5
    Views:
    3,988
    Simon Elliott
    Jan 7, 2005
  5. lutorm
    Replies:
    1
    Views:
    2,195
    Rapscallion
    May 21, 2005
Loading...

Share This Page