![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
2020.9从入门到精通
好吃的梅梅子
这个作者很懒,什么都没留下…
展开
-
异常处理是按照抛出表达式顺序进行的
#include <iostream>using namespace std;int main(){ int i; char ch; cout << "Please enter an integer and a character:\n"; try { cin >> i >> ch; if (i == 0)throw 0; if (ch == '!')throw '!'; } catch (int) { cout <原创 2020-12-07 20:40:39 · 79 阅读 · 0 评论 -
c++中的函数声明
如果自定义函数定义体在主函数之后,而在主函数之前没有声明这个函数,那么主函数就会查找不到这个函数,从而报错。若函数定义体在主函数之前,则可将声明和定义同时进行,省略声明部分。...原创 2020-12-07 17:21:30 · 765 阅读 · 0 评论 -
调用函数不是再次声明
今天犯了个十分低级的错误:#include using namespace std;int a = 1, b = 2;void swap(int a, int b);//pass by valuevoid swap(int a, int b){int temp;temp = a;a = b;b = temp;cout << “a” << a << " b" << b << endl;}void main(){v原创 2020-12-07 13:07:35 · 110 阅读 · 0 评论