是C++高手的请进来指点!
vcmfc 2001-02-10 12:58:00 这两个问题是两位网友问的问题,有些地方我也不解,请大虾指点!
问题1.如何取得这个结构的长度,不是大小?(knotery)
typedef struct tagIPHDR //Noram IP header
{
UCHAR h_len:4; //Lenght of the header
UCHAR Version:4; //Version
UCHAR Tos; //Server type(TOS)
USHORT Totlen; //Total lenght
USHORT ID; //ID
USHORT FlagOff; // Flags and Fragment Offset
UCHAR TTL; //Time to live
UCHAR Protocol; // Protocol
USHORT Checksum; // Checksum
IN_ADDR iaSrc; //Internet Address - Source
IN_ADDR iaDest; // Internet Address - Destination
}IPHDR,*PIPHDR;
typedef struct tagICMPHDR //Normal ICMP EchoRequest and EchoReply header
{
UCHAR type; //Type
UCHAR Code; //Code
USHORT Checksum; //Checksum
USHORT ID; //Identification
USHORT Seq; //Sequence
UINT OptData; //Option data
}ICMPHDR;
typedef struct tagICMPECHOREPLY
{
IPHDR iphdr;
ICMPECHOREQUEST IcmpReq;
char cData[256];
}ICMPECHOREPLY;
ICMPECHOREPLY 的长度是16640
Why?
在Think C++中提到的一种方法:
例:int c[] = { 1, 2, 3, 4 };
for(int i = 0; i < sizeof c / sizeof *c; i++)
c[i]++;
那么最佳的方法是啥????????????
问题2:这个错误该如何解决?,其错误原因是什么?
class A
{
public:
A();
private:
const char szBuf[20];
};
A::A() : szBuf("Bridge")//我估计是这里赋值是错误的,指点?
{;
}
正确的方法呢?
高手??大虾??高手??大虾??高手??大虾??高手??大虾??高手??大虾??