![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++初学
坏孩子啊
这个作者很懒,什么都没留下…
展开
-
C++初学笔记4(整型)
C++程序的模块叫函数;#include<iostream>的作用:在最终编译之前,使用iostream文件的内容替换该编译指令。 using namespace std;它使得程序可以使用std名称空间的定义;int froop(double t)调用函数froop()时候,应提供一个参数,该参数类型为double,而该函数将返回一个int值。例如int gval=froop...原创 2018-11-27 21:40:23 · 625 阅读 · 0 评论 -
字符数组应用
#include<iostream>#include <string>using namespace std;string name[50], num[50];int n;int main(){ void input_data(); void search(string find_name); string find_name; cout <<...原创 2019-03-24 17:22:24 · 225 阅读 · 0 评论 -
将一个二维数组行和列元素互换,存到另一个数组中
//将一个二维数组行和列元素互换,存到另一个数组中#include<iostream>#include<string>using namespace std;int main(){ int a[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } }; int b[3][2], i, j; cout << "array a:" &...原创 2019-03-28 19:25:33 · 7287 阅读 · 3 评论 -
VS2013中当鼠标点中括号中内容的时候,括号会变成黑色方框
解决方式:工具-----选项------图中红色箭头使用默认值,然后确定,这时候问题已经解决,如果不习惯默认字体,再把字体设置为自己喜欢的就可以了解决方式:...原创 2019-06-13 14:00:43 · 2135 阅读 · 0 评论 -
重载双目运算符
#include<iostream>using namespace std;class String{public: String(){ p = NULL; } String(char *str); friend bool operator>(String &string1, String &string2); void display();p...原创 2019-06-02 15:49:32 · 120 阅读 · 0 评论 -
重载流插入运算符
#include<iostream>using namespace std;class Complex{public: Complex(){ real = 0; imag = 0; } Complex(double r, double i){ real = r; imag = i; } Complex operator+(Complex&c2); friend...原创 2019-06-02 16:24:43 · 190 阅读 · 0 评论 -
重载流提取运算符
#include<iostream>using namespace std;class Complex{public: friend ostream&operator<<(ostream&, Complex&); friend istream&operator>>(istream&, Complex&...原创 2019-06-02 16:43:41 · 578 阅读 · 0 评论 -
异常处理
#include <cmath>#include <iostream>using namespace std;int main(){ double triangle(double, double,double); double a, b, c; cin >> a >> b >> c; try { while (a ...原创 2019-06-08 13:26:36 · 106 阅读 · 0 评论 -
在函数嵌套的情况下检测异常处理 try 和catch 以及throw
#include <iostream>#include<cmath>using namespace std;int main(){ void f1(); try { f1(); } catch (double) { cout << "ERROR0" << endl; } cout << "end0"...原创 2019-06-08 13:52:05 · 390 阅读 · 0 评论 -
公用继承
#include<iostream>#include<string>using namespace std;class Student{public: void get_value() { cin >> num >> name >> sex; } void display() { cout << ...原创 2019-06-03 09:00:13 · 161 阅读 · 0 评论 -
输出数组中的最大值和最大值所在的行和列的两种方式
#include<iostream>using namespace std;int main(){ int i, j, row = 0, colum = 0, max; int a[3][4] = { { 1, 2, 3, 4 }, { 2, 3, 4, 5 }, {454,53,34,56} }; max = a[0][0]; for (i = 0; i <= 2...原创 2019-03-24 14:40:11 · 2494 阅读 · 0 评论 -
10个数从小到大排序两种方式(起泡法和选择法)
#include<iostream>using namespace std;int main(){ int a[11]; int i; int j; int t; cout << "input 10 numbers:" << endl; for (i = 1; i < 11; i++) ...原创 2019-03-24 10:30:00 · 5379 阅读 · 0 评论 -
C++练习题
1.输入 3 个整数 a、 b以及c,请把这三个数从小到大输出#include<iostream>using namespace std;int main(){ int a, b, c,t; cin >> a; cin >> b; cin >> c; cout << "初始数据" <..原创 2018-11-23 12:28:34 · 12681 阅读 · 0 评论 -
C++初学笔记3转义序列
数据类型、运算符关于#include<iomanip>可以参考https://blog.csdn.net/akof1314/article/details/4625888#include<iostream>该编译指令导致预处理将iostream文件的内容添加到程序中。这是一种典型的预处理器操作:在代码被编译之前,替换或添加文本。iostream文件叫做包含文...原创 2018-11-20 10:22:42 · 190 阅读 · 0 评论 -
C++学习笔记2编译过程
C++编译过程主要分为,预处理、编译、汇编、链接四个过程。如下图所示:第一步:预处理将源代码的.c 、.cpp 、.h 等文件包含到一个文件中。在这个过程中会使用一些预处理指令要求编译器使用什么样的方式包含这些文件。预处理结束之后对于c语言编译器会生成一个.i 文件。C++会生成.ii文件。[新手略过]预编译过程主要处理那些源代码中以#开始的预编译指令,主要处理规则如下:...转载 2018-11-17 10:28:43 · 325 阅读 · 0 评论 -
C++初学笔记1
1.C编译器是把C代码转换成计算机内部指令的程序。2.C++在C语言的基础上嫁接了面向对象编程工具。(面向对象编程是一门哲学,它通过对语言建模来适应问题,而不是对问题建模以适应语言),C++几乎是C的超集,这意味着任何C程序差不多就是一个C++程序。3.#include<stdio.h>告诉编译器把stdio.h中的内容包含在当前程序中。stdio,h是C编译器软件包的标准部分...原创 2018-11-17 10:10:14 · 161 阅读 · 0 评论 -
C++初学笔记5数组和字符串
1.C++没有提供自动防止超出整型限制的功能,可以使用头文件climits来确定限制情况。2.常量33L的类型为long,常量33的类型为int3.要创建数组,可使用声明语句,数组声明应指出以下三点:1.存储在每个元素中的值得类型2.数组名3.数组中的元素数。在C++中可以通过修改简单变量的声明,添加中括号(其中包含元素数目)来完成数组声明。通用格式typeName arrayName[a...原创 2018-12-07 20:36:57 · 145 阅读 · 0 评论 -
C++初学笔记六(string)
1.使用string类,必须在程序中包含头文件string。String类位于名称空间std中,所以必须提供一条using编译指令2.不能将一个数组付给另一个数组,但可以将一个string对象赋给另一个string对象: char charr1[20];//create an empty array char charr2[20] = "jaguar";//create a...原创 2018-12-09 12:35:49 · 148 阅读 · 0 评论 -
指针的方式按从大到小顺序输出(两种方式)
#include<iostream>#include <string>using namespace std;int main(){ int *p1, *p2, *p, a, b; cout << "please input a he b" << endl; cin >> a >> b; p1 = &a...原创 2019-03-24 21:38:42 · 757 阅读 · 0 评论 -
例6.4 输入a,b,c3个整数,按从大到小顺序输出。。。不知道为什么没有输出内容,编译通过的
#include<iostream>using namespace std;int main(){ void exchange(int*, int*, int*); int a, b, c, *p1, *p2, *p3; cout << "请输入三个值" << endl; cin >> a >> b >> c &...原创 2019-03-30 10:01:37 · 208 阅读 · 0 评论 -
求两个数中的最大者,(用函数指针变量调用函数)
#include<iostream>using namespace std;int main(){ int max(int x, int y); int( *p)(int,int);//定义一个指针变量指向函数,函数值是整型 int a, b, m; p = max; cin >> a >> b; m = p(a, b); cout <...原创 2019-03-30 14:44:25 · 1422 阅读 · 0 评论 -
多重继承派生类构造函数
#include<iostream>#include<string>using namespace std;class Teacher{public: Teacher(string nam, int a, string t) { name = nam; age = a; title = t; } void display() { cou...原创 2019-06-03 16:54:28 · 1498 阅读 · 0 评论