1、下面程序的正确输出结果为()
class test
{
public:
void print()
{
cout<<"test"<<endl;
}
};
int main(void)
{
test *t = new test();
t->print();
t = NULL;
t->print();
return 0;
}
A、编译不通过 B、运行时必然出错退出 C、运行时可能出错退出
D、test E、test test F、test 随机信息
print是一个类级别的东西,也就是说它和类的实例(或者类的对象)没有任何关系,这也就是说“并未使用this指针”,在这种情况下,print仅与test的类型有关,而不管t是什么东西,只要是类类型的指针就可以调用这个函数。
对象级别的东西,比如类中的某个非静态成员变量,这种东西和类的实例有关,因此它使用this指针。
http://topic.csdn.net/u/20120428/22/06ecf02b-45a3-41e5-8eee-2e0be73a31db.html
2、在小端字节序的机器上执行下列代码的输出为多少?
union UData
{
unsigned char btVals[4];
unsigned int uiVal;
};
UData d;
int main(void)
{
d.uiVal = 0x01020408;
unsigned int btSum = (d.btVals[0]<<5)+(d.btVals[1]<<3)+(d.btVals[2]<<1)+(d.btVals[3]<<0);
cout<<btSum<<endl;
return 0;
}
3、下列代码的输出为()
class CClassA
{
public:
virtual void Print()
{
printf("A ");
}
};
void PrintFunc(CClassA a)
{
a.Print();
}
class CClassB:public CClassA
{
public:
virtual void Print()
{
printf("B ");
}
};
void PrintFunc(CClassA *pa)
{
pa->Print();
}
int main(void)
{
CClassB b;
PrintFunc(b);
PrintFunc(&b);
return 0;
}
A、A A B、A B C、B A
D、B B E、程序无法通过编译 F、运行后程序异常终止
4、以下关于const 的用法错误的是()
A、 const int a = 10;
B、 int func(void) const
C、 const int func(void)
D、
class A
{
public:
void SetStr(const string& str)
{
_str = str;
}
private:
string _str;
};
E、
class A
{
public:
const string& void GetStr(void)const
{
return _str;
}
private:
string _str;
};
5、读下题
class A
{
public:
A();
virtual ~A();
int a;
};
class B : public A
{
public:
int b;
};
A *a = new B;
B* b1 = dynamic_cast<B *>(a);
B* b2 = static_cast<B *>(a);
B* b3 = reinterpret_cast<B *>(a);
假如b1的值为 0X12345678,则b2、b3可能的值为()
A、0X12345678 0X12345674
B、0X12345674 0X12345674
C、0X12345678 0X12345678
D、0X12345674 0X12345678
分享到:
相关推荐
《恋与肥宅喵》 Made For the 48 hours Game Jam hold by Perfect World(完美世界) on Children’s day. 参加完美世界举办的48小时Game Jam时制作。
语言:English (United States) 在每个选项卡背景上都包含游戏“完美世界手机”的高清壁纸图像。 安装此扩展程序,以在每个新选项卡上获得《完美世界》的高清图像! 我们始终会更新图像,因此请随时检查......
v1.1 样图用 Perfect World 完美世界 模型生成,推荐首选用这个模型。想要长腿或者更多可塑性的模型推荐Lucky Strike Mix,配合的也不错,脸会显得稍幼一点。 二次元推荐用meinamix或facebombmix v1.1 由完美世界...
构建您的 PW 网络服务器面板安装Laravel 4.2 及以下该项目是通过 Composer 在 Laravel 框架下构建的您可以按照此链接将 Composer Global 安装到您的系统中接下来,从终端更新作曲家:(如果您的作曲家正确设置为全局...
And in a perfect world, those who produce the best code are the most successful. But in our perfectly messy world, success also depends on how you work with people to get your job done. In this ...
In a perfect world, software engineers who produce the best code are the most successful. But in our perfectly messy world, success also depends on how you work with people to get your job done. In ...
perfect world 155 logintool
receive proper RS-274X files, it would be a perfect world.” The new formats are more complex and less transparent to the user, and new implementations inevitably have bugs. Using the common poor ...
Contents Module Overview 1 Lesson 1: Memory 3 Lesson 2: I/O 73 Lesson 3: CPU 111 Module 3: Troubleshooting Server Performance ...Troubleshooting server performance-based support calls requires ...
KUBIKOS is perfect for stylized games. Fully modular assets are easy to piece together in a variety of combinations. +Universal Render Pipeline (URP) support +Includes 458 Unique prefab assets +...
图像ISP 白平衡算法,共4种主流算法的实现
Beginning SVG: A Practical Introduction to SVG using Real-World Examples By 作者: Alex Libby ISBN-10 书号: 1484237595 ISBN-13 书号: 9781484237595 Edition 版本: 1st ed. 出版日期: 2018-09-07 pages 页数:...
#perfect world cases Scenario : Create listing on the marketplace Given I have an image "my-unique-digital-art.jpg" When I press "Create Listing" And I fill name as "Beyonce's Baby" Then Scenario ...
This is the perfect time for starting a new economic model, based on social capitalism, which values humanity. The bailouts and stimulus packages are a short-term solution that does not really ...
“HTML5 Graphing and Data Visualization Cookbook” is the perfect break into the world of Canvas, charts, and graphs in ... progressive way so it can be read from start to finish, as well as be used as a...
Network Security: Private Communication in a Public World, Second Edition By Charlie Kaufman, Radia Perlman, Mike Speciner ............................................... Publisher: Prentice Hall ...
As well as a constant Vision: the search for the perfect sound and the recognition of the Pro DG Systems brand as world leader in the field of high-end professional audio. Nowadays Pro DG Systems...
Using real-world case studies that leverage the popular Python Machine Learning ecosystem, this book is your perfect companion for learning the art and science of Machine Learning to become a ...
WordPress 24-Hour Trainer, 3rd Edition provides a comprehensive, unique book package ...WordPress 24-Hour Trainer, 3rd Edition is your perfect real-world guide to fully leveraging this powerful platform.