Hi,
After a few days of tying to find the problems to the
following code, I thought I would ask, here is the code
followed my the errors.
----IPacket.h----
class IPacket
{
public:
virtual char const * const VGetType() const=0;
virtual char const * const VGetData() const=0;
virtual u_long VGetSize() const =0;
virtual ~IPacket() { }
};
----BinPacket.h-----
#include <winsock2.h>
#include "CPacket.h"
#include <string.h>
#include <sys/types.h>
#include <assert.h>
class BinaryPacket : public IPacket
{
protected:
char *m_Data;
public:
inline BinaryPacket(char const * const data, u_long size);
inline BinaryPacket(u_long size);
virtual ~BinaryPacket() { SAFE_DELETE(m_Data); }
virtual char const * const VGetType() const { return g_Type; }
virtual char const * const VGetData() const { return m_Data; }
virtual u_long VGetSize() const { return ntohl(*(u_long *)m_Data); }
inline void MemCpy(char const *const data, size_t size, int destOffset);
static const char *g_Type;
};
(Other code here for the implementation of above methods. )
Here are the errors:
error C2146: syntax error : missing ';' before identifier 'VGetSize'
error C2253: 'IPacket::VGetSize' : pure specifier only applies to virtual function - specifier ignored
error C2433: 'IPacket::u_long' : 'virtual' not permitted on data declarations
error C2501: 'IPacket::u_long' : missing storage-class or type specifiers
warning C4183: 'VGetSize': missing return type; assumed to be a member function returning 'int'
As far as I can see there is NOTHING wrong with this code, it is the same as in the authors book. The only thing I can think of is since I split the code into diffrent files, its having some problem. (?)
I put the following statments in so the compiler will not include then more than twice
#ifndef IBinaryPacket_H
#define IBinaryPacket_H
But this also does not herlp, any ideas?
Thank you.
After a few days of tying to find the problems to the
following code, I thought I would ask, here is the code
followed my the errors.
----IPacket.h----
class IPacket
{
public:
virtual char const * const VGetType() const=0;
virtual char const * const VGetData() const=0;
virtual u_long VGetSize() const =0;
virtual ~IPacket() { }
};
----BinPacket.h-----
#include <winsock2.h>
#include "CPacket.h"
#include <string.h>
#include <sys/types.h>
#include <assert.h>
class BinaryPacket : public IPacket
{
protected:
char *m_Data;
public:
inline BinaryPacket(char const * const data, u_long size);
inline BinaryPacket(u_long size);
virtual ~BinaryPacket() { SAFE_DELETE(m_Data); }
virtual char const * const VGetType() const { return g_Type; }
virtual char const * const VGetData() const { return m_Data; }
virtual u_long VGetSize() const { return ntohl(*(u_long *)m_Data); }
inline void MemCpy(char const *const data, size_t size, int destOffset);
static const char *g_Type;
};
(Other code here for the implementation of above methods. )
Here are the errors:
error C2146: syntax error : missing ';' before identifier 'VGetSize'
error C2253: 'IPacket::VGetSize' : pure specifier only applies to virtual function - specifier ignored
error C2433: 'IPacket::u_long' : 'virtual' not permitted on data declarations
error C2501: 'IPacket::u_long' : missing storage-class or type specifiers
warning C4183: 'VGetSize': missing return type; assumed to be a member function returning 'int'
As far as I can see there is NOTHING wrong with this code, it is the same as in the authors book. The only thing I can think of is since I split the code into diffrent files, its having some problem. (?)
I put the following statments in so the compiler will not include then more than twice
#ifndef IBinaryPacket_H
#define IBinaryPacket_H
But this also does not herlp, any ideas?
Thank you.