文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > 高等教育 > 工学 > Thinking_in_C++_annotated_solution_guide(charpter_5).
侵权投诉

Thinking_in_C++_annotated_solution_guide(charpter_5).

C++编程思想 第五章答案

Chapter 5

5-1

Create a class with public, private, and protected data members and function members. Create an object of this class and see what kind of compiler messages you get when you try to access all the class members.

(Left to the reader)

5-2

Write a struct called Lib that contains three string objects a, b, and c. In main( ) create a Lib object called xand assign to x.a, x.b, and x.c. Print out the values. Now replace a, b, and c with an array of string s[3]. Show that your code in main( ) breaks as a result of the change. Now create a class called Libc, with private string objects a, b, and c, and member functions seta( ), geta( ), setb( ), getb( ), setc( ), and getc( ) to set and get the values. Write main( ) as before. Now change the private string objects a, b, and c to a privatearray of string s[3]. Show that the code in main( ) does not break as a result of the change.

(Left to the reader)

5-3

Create a class and a global friend function that manipulates the private data in the class.

(Left to the reader)

5-4

Write two classes, each of which has a member function that takes a pointer to an object of the other class. Create instances of both objects in main( ) and call the aforementioned member function in each class.

Solution:

//: S05:PointToMeAndYou.cpp

第1页

你可能喜欢

热门文档

相关文档

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email