-
指针类型的引用查看全部
-
结构体类型的引用查看全部
-
#include <string.h> #include <iostream> using namespace std; int main(void) { //在堆中申请100个char类型的内存 char *str = new char[100]; //拷贝Hello C++字符串到分配的堆中的内存中 strcpy(str, "Hello imooc"); //打印字符串 cout<<str<<endl; //释放内存 delete []str; str=NULL; return 0; }查看全部
-
#include <iostream> using namespace std; /** *函数功能:返回a和b的最大值 *a和b是两个整数 */ int getMax(int a, int b) { return a > b ? a : b; } /** * 函数功能:返回数组中的最大值 * arr:整型数组 * count:数组长度 * 该函数是对上面函数的重载 */ int getMax(int *arr,int count) { //定义一个变量并获取数组的第一个元素 int temp=arr[0]; for(int i = 1; i < count; i++) { //比较变量与下一个元素的大小 if(temp<arr[i]) { //如果数组中的元素比maxNum大,则获取数组中的值 temp=arr[i]; } } return temp; } int main(void) { //定义int数组并初始化 int numArr[3] = {3, 8, 6}; //自动调用int getMax(int a, int b) cout << getMax(numArr[0],numArr[2]) << endl; //自动调用返回数组中最大值的函数返回数组中的最大值 cout << getMax(numArr,3) << endl; return 0; }查看全部
-
#include <iostream> using namespace std; /** *函数功能:返回a和b的最大值 *a和b是两个整数 */ int getMax(int a, int b) { return a > b ? a : b; } /** * 函数功能:返回数组中的最大值 * arr:整型数组 * count:数组长度 * 该函数是对上面函数的重载 */ int getMax(int *arr,int count) { //定义一个变量并获取数组的第一个元素 int temp=arr[0]; for(int i = 1; i < count; i++) { //比较变量与下一个元素的大小 if(temp<arr[i]) { //如果数组中的元素比maxNum大,则获取数组中的值 temp=arr[i]; } } return temp; } int main(void) { //定义int数组并初始化 int numArr[3] = {3, 8, 6}; //自动调用int getMax(int a, int b) cout << getMax(3,6) << endl; //自动调用返回数组中最大值的函数返回数组中的最大值 cout << getMax(numArr,3) << endl; return 0; }查看全部
-
a = 10查看全部
-
函数参数默认值:有默认参数值的参数必须在参数表的最右端查看全部
-
const3查看全部
-
const在下列情况下不能使用2查看全部
-
const在下列情况下不能使用查看全部
-
const在下列情况下不能使用查看全部
-
内联函数; 1.内联编译是建议性的,由编译器决定。 2.逻辑简单,调用频繁的函数建议使用内联。 3.递归函数无法使用内联方式。查看全部
-
内联函数; 1.内联编译是建议性的,由编译器决定。 2.逻辑简单,调用频繁的函数建议使用内联。 3.递归函数无法使用内联方式。查看全部
-
有默认值的参数必须写在最有端查看全部
-
类型 *&指针引用名=指针;查看全部
举报
0/150
提交
取消