摘要:#include <iostream>using namespace std; /*四位同学中有一位是做了好事,不留名,其中,A说:不是我B说:是CC说:是DD反驳:他胡说已知3人说的是真话,编程序找出谁做了好事儿*/class Student{public: Student(bool isEqua 阅读全文
STL——容器,算法和迭代器的基本概念
2018-10-23 20:26 by mengjuanjuan1994, 491 阅读, 0 推荐, 收藏,
摘要:容器:序列式容器;关联式容器。 迭代器:是一个类,类中封装一个指针,可以当成指针来用。 算法:解决某一个问题的有限步骤。 算法与容器是分离的,迭代器起到了连接算法与迭代器的作用: #include <iostream>using namespace std; //算法int mycount(int* 阅读全文
异常处理
2018-10-21 21:18 by mengjuanjuan1994, 128 阅读, 0 推荐, 收藏,
摘要:1. 异常基本语法 #include<iostream>using namespace std;int divide(int x, int y){ if(y == 0) { throw y; } return x / y;}int main(){ try { cout << "5 / 2 = " < 阅读全文
函数类型转换
2018-10-21 14:07 by mengjuanjuan1994, 218 阅读, 0 推荐, 收藏,
摘要:1. static_cast 用于内置的数据类型(int, char) eg1: int a = 97; char c = static_cast<char>(a); 用于具有继承关系的指针或者引用 eg2: class Animal { }; class Cat: public Animal { 阅读全文
函数模板和类模板
2018-10-13 19:43 by mengjuanjuan1994, 174 阅读, 0 推荐, 收藏,
摘要:1. 函数模板 1.1 函数模板使用的基本方法 #include <iostream>using namespace std; template<class T> //只对其下面程序中的第一个函数生效void MySwap(T &a, T &b){ T temp = a; a = b; b = te 阅读全文
浙公网安备 33010602011771号