What's wrong with that

M

mosfet

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> ]
 
G

Gavin Deane

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
 
M

mosfet

Gavin Deane a écrit :
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.


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.
 
M

mosfet

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
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top