一:
class A
{
public:
A()
{
VirtualFunc();
}
virtual ~A()
{
printf( "base ~A\r\n" );
}
public:
virtual void VirtualFunc()
{
printf( "base VirtualFunc\r\n" );
};
void Func()
{
printf( "base Func\r\n" );
}
protected:
private:
};
class B : public A
{
public:
B()
{
VirtualFunc();
}
~B()
{
printf( "derive ~B\r\n" );
}
public:
virtual void VirtualFunc()
{
printf( "derive VirtualFunc\r\n" );
};
void Func()
{
printf( "derive Func\r\n" );
}
protected:
private:
};
int _tmain(int argc, _TCHAR* argv[])
{
A *pA = new B;
pA->Func();
delete( pA );
return 0;
}
二:
把一个32位无符号整数的位交换,例如第一位和最后一位对换以此类推
unsigned int Reverse( unsigned int n )
{
unsigned int j = 0;
for ( int i=0;i <32;i++ )
{
j = j < <1;
j = j ¦ ( n &0x1 );
n = n>>1;
}
return j;
}
三:
二叉树的中序遍历
四:
描述C++类的V-table,也就是virtual是如何实现
还有些没记住,自己做的时候也错了些,还是基础功底不扎实
二:
x = ((x&0x55555555) < <1)+((x&0xAAAAAAAA)>>1);
x = ((x&0x33333333) < <2)+((x&0xCCCCCCCC)>>2);
x = ((x&0x0F0F0F0F) < <4)+((x&0xF0F0F0F0)>>4);
x = ((x&0x00FF00FF) < <8)+((x&0xFF00FF00)>>8);
x = ((x) < <16)+((x)>>16);
阅读(2198) | 评论(0) | 转发(0) |