c++ primer plus 习题答案(4)】的更多相关文章

c++ primer plus 习题答案用的是第五版,IDE仍然是vs2013.我只标注了题号,具体的题目找下书上对应内容吧. p110.8 #include<iostream> #include<string> #include<cstring> char* getname(char*); struct pissza { char *pt; int diameter; int weight; }; using namespace std; int main(void)…
p475.2 //头文件: class Cd{ private: char *performers; char *label; int selections; double playtime; public: Cd(char *s1, char *s2, int n, double x); Cd(const Cd & st); Cd(); virtual ~Cd(); virtual void Report()const; Cd & operator = (const Cd & s…
p427.4 //头文件: #include<iostream> #ifndef STACK_H_ #define STACK_H_ typedef unsigned long Item; class Stack{ private: }; Item *pitems; int size; int top; public: Stack(); Stack(const Stack &st); ~Stack(); bool isempty()const; bool isfull()const;…
p425.1 #include<iostream> #include<cstring> #include<cstdlib> using namespace std; class Cow{ ]; char *hobby; double weight; public: Cow(); Cow(const char *nm, const char *ho, double wt); Cow(const Cow &c); ~Cow(); Cow &operator=…
p333.7 #include<iostream> #include<cstring> #include<cstdlib> using namespace std; class Plorg{ private: ]; int CI; public: Plorg(); void index(); void show()const; }; Plorg::Plorg(char *ar, int ct){ strcpy(fullname, ar); CI = ct; } void…
p333.3 #include<iostream> #include<cstdlib> #include<cstring> #include<string> using namespace std; class Golf{ private: ; char fullname[Len]; int handicap; public: Golf(char name[Len], int bt); void showgolf() const; }; void setgo…
p296.3 #include<iostream> #include<cstdlib> #include<string> #include<cstring> #include<new> using namespace std; struct chaff { ]; int slag; }; void setarray(chaff *pt); void showarray(chaff *pt); int main(){ ]; chaff ar[],…
p221.8 #include<iostream> #include<cstdlib> #include<cstring> using namespace std; ; struct student{ char fullname[SLEN]; char hobby[SLEN]; int ooplevel; }; int getinfo(student pa[], int n); void display1(student st); void display2(const…
目前正在刷<C++Primer>这本书,会在博客上记录课后习题答案,答案仅供参考. 因为水平有限,如有有误之处,希望大家不吝指教,谢谢! 目录地址 使用的系统为:win 10,编译器:VS2017,答案用markdown写的. 第1章 开始&&第2章 变量和基本类型   第3章 字符串.向量和数组   第4章 表达式   第5章 语句   第6章 函数   第7章 类   第8章 IO库   第9章 顺序容器   第10章 泛型算法   第11章 关联容器   第12章 动态内…
<C++Primer>第五版习题答案--第五章[学习笔记] ps:答案是个人在学习过程中书写,可能存在错漏之处,仅作参考. 作者:cosefy Date: 2020/1/15 第五章:语句 练习5.3: 代码可读性降低了. while(val<=10) sum+=val,++val; 练习5.4: iter未初始化. if语句中的status超过作用范围,且status在while中进行了判断. 练习5.5: #include<iostream> #include<ve…