
C++学习
文章平均质量分 76
yin4ever
这个作者很懒,什么都没留下…
展开
-
C++ 习题整理(1)
习题2.1int、long 和short 类型之间有什么差别? 【解答】 它们的最小存储空间不同,分别为16 位、32 位和16 位。一般而言,short 类型为半个机器字(word)长,int 类型为一个机器字长,而long 类型为一个或两个机器字长(在32 位机器中,int 类型和long 类型的字长通常是相同的)。因此,它们的表示范围不同。习题2.2 unsign原创 2014-03-04 13:59:16 · 1229 阅读 · 0 评论 -
数据结构-线性表 (C++)
#include using namespace std;const int DefaultSize=100;//默认线性表大小templateclass LinearList{public:LinearList(int MaxListSize = DefaultSize);~LinearList() {delete [] elements;原创 2014-03-10 18:45:02 · 573 阅读 · 0 评论 -
C++习题整理(2)
习题3.6 解释string 类型的输入操作符和getline 函数分别如何处理空白字符。 【解答】 string 类型的输入操作符对空白字符的处理:读取并忽略有效字符(非空白字符)之前所有的空白字符,然后读取字符直至再次遇到空白字符,读取终止(该 空白字符仍留在输入流中)。 getline 函数对空白字符的处理:不忽略行开头的空白字符,读取字符直至遇到 换行符,读取终止并丢弃换行原创 2014-03-05 18:37:16 · 818 阅读 · 0 评论 -
C++习题整理(3)
习题4.1 假设get_size 是一个没有参数并返回int 值的函数,下列哪些定义是非法的? 为什么? unsigned buf_size = 1024 (a) int ia[buf_size]; (b) int ia[get_size()]; (c) int ia[4*7-14]; (d) char st[11] = "fundamental" 【解答】 (a)非法,原创 2014-03-05 22:10:54 · 1301 阅读 · 0 评论 -
数据结构 单链表 (C++)
#include using namespace std;templatestruct Node{T data;Node *next;};template class SingleList{public:SingleList(){first=new Node;first->next=NULL;length = 0;}S原创 2014-03-11 23:06:11 · 612 阅读 · 0 评论 -
C++ sizeof问题
关于C++中类所占的内存空间总结,见bluesky的文章:http://blog.sina.com.cn/s/blog_69c189bf0100mkeu.html阿里巴巴有一道笔试题,问sizeof(a)的大小#pragma pack(2)class A{int i;union U{char buff[13];int i;原创 2014-03-27 11:10:48 · 573 阅读 · 0 评论