What's wrong with that

Discussion in 'C++' started by mosfet, Feb 16, 2007.

  1. mosfet

    mosfet Guest

    class CSyncClient
    {
    public:
    CSyncClient(void);
    virtual ~CSyncClient(void);


    //DECLARE_PROPERTY(Login, char*);

    friend class Login_;

    template<class TYPE>
    struct Login_ : public BaseProperty<TYPE>
    {
    virtual void putprop(TYPE p_Value)
    {
    CSyncClient::m_pSyncClientSession->SetLogin(p_Value);
    }
    };
    struct Login_<char*> Login;


    protected:
    CSyncClientSession* m_pSyncClientSession;
    };






    I get :

    left of '->SetLogin' must point to class/struct/union/generic type
    1> c:\htc\ui\replication\SyncClient.h(109) : while compiling
    class template member function 'void
    CSyncClient::Login_<TYPE>::putprop(TYPE)'
    1> with
    1> [
    1> TYPE=char *
    1> ]
    1> c:\htc\ui\replication\SyncClient.h(114) : see reference to
    class template instantiation 'CSyncClient::Login_<TYPE>' being compiled
    1> with
    1> [
    1> TYPE=char *
    1> ]
     
    mosfet, Feb 16, 2007
    #1
    1. Advertising

  2. mosfet

    Gavin Deane Guest

    On 16 Feb, 10:08, mosfet <> wrote:
    > class CSyncClient
    > {
    > public:
    > CSyncClient(void);
    > virtual ~CSyncClient(void);
    >
    > //DECLARE_PROPERTY(Login, char*);
    >
    > friend class Login_;
    >
    > template<class TYPE>
    > struct Login_ : public BaseProperty<TYPE>
    > {
    > virtual void putprop(TYPE p_Value)
    > {
    > CSyncClient::m_pSyncClientSession->SetLogin(p_Value);


    What are you trying to do in the line above? m_pSyncClientSession is
    not a static member of CSyncClient. Every CSyncClient has its own
    m_pSyncClientSession member. If you want to use the
    m_pSyncClientSession member, you need a CSyncClient object because
    inside a CSyncClient object is the only place an m_pSyncClientSession
    member exists.

    > }
    > };
    > struct Login_<char*> Login;
    >
    > protected:
    > CSyncClientSession* m_pSyncClientSession;
    >
    > };


    It's not clear what you are trying to do, but at a wild guess it looks
    like maybe the put_prop function should be in the CSyncClient class.

    template <typename TYPE>
    virtual void put_prop(TYPE p_Value)
    {
    m_pSyncClientSession->SetLogin(p_Value);
    }

    Gavin Deane
     
    Gavin Deane, Feb 16, 2007
    #2
    1. Advertising

  3. mosfet

    mosfet Guest

    Gavin Deane a écrit :
    > On 16 Feb, 10:08, mosfet <> wrote:
    >> class CSyncClient
    >> {
    >> public:
    >> CSyncClient(void);
    >> virtual ~CSyncClient(void);
    >>
    >> //DECLARE_PROPERTY(Login, char*);
    >>
    >> friend class Login_;
    >>
    >> template<class TYPE>
    >> struct Login_ : public BaseProperty<TYPE>
    >> {
    >> virtual void putprop(TYPE p_Value)
    >> {
    >> CSyncClient::m_pSyncClientSession->SetLogin(p_Value);

    >
    > What are you trying to do in the line above? m_pSyncClientSession is
    > not a static member of CSyncClient. Every CSyncClient has its own
    > m_pSyncClientSession member. If you want to use the
    > m_pSyncClientSession member, you need a CSyncClient object because
    > inside a CSyncClient object is the only place an m_pSyncClientSession
    > member exists.
    >
    >> }
    >> };
    >> struct Login_<char*> Login;
    >>
    >> protected:
    >> CSyncClientSession* m_pSyncClientSession;
    >>
    >> };

    >
    > It's not clear what you are trying to do, but at a wild guess it looks
    > like maybe the put_prop function should be in the CSyncClient class.
    >
    > template <typename TYPE>
    > virtual void put_prop(TYPE p_Value)
    > {
    > m_pSyncClientSession->SetLogin(p_Value);
    > }
    >
    > Gavin Deane
    >

    Dooh! you are right.
     
    mosfet, Feb 16, 2007
    #3
  4. mosfet

    mosfet Guest

    Now it works butr I would like to write a macro, I am trying this

    #define DECLARE_PROPERTY(NAME, TYPE) \
    friend class NAME##_; \
    template<class TYPE> \
    class NAME##_ \
    { \
    }; \

    but it doesn't work

    error C2332: 'class' : missing tag name
     
    mosfet, Feb 16, 2007
    #4
  5. On Feb 16, 11:46 am, mosfet <> wrote:
    > Now it works butr I would like to write a macro, I am trying this
    >
    > #define DECLARE_PROPERTY(NAME, TYPE) \
    > friend class NAME##_; \
    > template<class TYPE> \
    > class NAME##_ \
    > { \
    >
    > }; \
    >
    > but it doesn't work
    >
    > error C2332: 'class' : missing tag name


    Run it through the pre-processor and look at the code produced and you
    might get an idea of what's wrong. For you that means right-clicking
    the project, Properties, C/C++, Preprocessor, Generate Preprocessed
    File = Yes.

    --
    Erik Wikström
     
    =?iso-8859-1?q?Erik_Wikstr=F6m?=, Feb 16, 2007
    #5
    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. Salisha Khan
    Replies:
    1
    Views:
    11,696
    JohnFol
    Aug 1, 2003
  2. Replies:
    2
    Views:
    403
  3. Pial
    Replies:
    4
    Views:
    57,064
    Phatman
    Aug 27, 2010
  4. Paul Leventis

    Re: Quartus bug or wrong VHDL?

    Paul Leventis, Jun 24, 2003, in forum: VHDL
    Replies:
    0
    Views:
    2,510
    Paul Leventis
    Jun 24, 2003
  5. Matthew
    Replies:
    7
    Views:
    868
    Priscilla Walmsley
    Jan 7, 2005
Loading...

Share This Page