G
groleo
Hi.
I have some problems with variables
I have the classes given below:
The problem is when I try to acces Commands().sock->m_sock, from
inside Message();
When I'm using m_sock inside Commands(), it has one value.
When I'm using m_sock inside Message() it has another value.
The thing is that i'm not modifying the m_sock value;
class Socket {
public:
Socket(){};
virtual ~Socket(){};
bool create();
bool bind ( const int port );
bool listen() const;
bool accept ( Socket& ) const;
bool connect ( const std::string host, const int port
);
// Data Transimission
bool send ( const std::string ) const;
int recv ( std::string& ) const;
void set_non_blocking ( const bool );
bool is_valid() const { return m_sock != -1; }
private:
int m_sock;
sockaddr_in m_addr;
};
class Handler {
public:
Handler() {} ;
virtual ~Handler(){};
virtual void OnStartElement(){};
virtual void OnElementEnd(){};
virtual void OnCharacter(){};
Socket* sock;
};
class Commands : public Handler {
public:
Commands();
virtual ~Commands() {};
void OnStartElement();
void OnElementEnd();
void OnCharacter();
Socket* sock;
};
class Message : public Handler {
public:
Message();
virtual ~Message() {};
void OnStartElement();
void OnElementEnd();
void OnCharacter();
};
I have some problems with variables
I have the classes given below:
The problem is when I try to acces Commands().sock->m_sock, from
inside Message();
When I'm using m_sock inside Commands(), it has one value.
When I'm using m_sock inside Message() it has another value.
The thing is that i'm not modifying the m_sock value;
class Socket {
public:
Socket(){};
virtual ~Socket(){};
bool create();
bool bind ( const int port );
bool listen() const;
bool accept ( Socket& ) const;
bool connect ( const std::string host, const int port
);
// Data Transimission
bool send ( const std::string ) const;
int recv ( std::string& ) const;
void set_non_blocking ( const bool );
bool is_valid() const { return m_sock != -1; }
private:
int m_sock;
sockaddr_in m_addr;
};
class Handler {
public:
Handler() {} ;
virtual ~Handler(){};
virtual void OnStartElement(){};
virtual void OnElementEnd(){};
virtual void OnCharacter(){};
Socket* sock;
};
class Commands : public Handler {
public:
Commands();
virtual ~Commands() {};
void OnStartElement();
void OnElementEnd();
void OnCharacter();
Socket* sock;
};
class Message : public Handler {
public:
Message();
virtual ~Message() {};
void OnStartElement();
void OnElementEnd();
void OnCharacter();
};