当前位置: 首页 > news >正文

html5 手机网站 模板php网站管理

html5 手机网站 模板,php网站管理,上海域邦建设集团网站,商城网站建设都需要多少钱代码区 存放函数体的二进制代码 由操作系统进行管理 全局区 存放全局变量和静态变量以及常量 存放全局变量 静态变量 常量#xff08;字符串常量 全局const常量#xff09; 栈区 由编译器自动分配释放#xff0c;存放函数的参数值#xff0c;局部变量等。不要返回局部…代码区 存放函数体的二进制代码 由操作系统进行管理 全局区  存放全局变量和静态变量以及常量 存放全局变量 静态变量 常量字符串常量 全局const常量 栈区 由编译器自动分配释放存放函数的参数值局部变量等。不要返回局部变量的地址 堆区 由程序员分配和释放 若程序员不释放程序结束的时候由操作系统回收 cpp 中使用new进行开辟内存 new操作符 c中利用new操作符在堆区开辟内存 需要程序员手动释放。 #include iostream #include mathutil.hpp #include string using namespace std; int *func() {int *p new int(10);return p; } void test1() {int *array new int[10];for (int i 0; i 10; i) {array[i] 100 i;}for (int i 0; i 10; i) {std::cout array[i] std::endl;}// 释放数组需要在变量前➕一个【】delete[] array; } int main(int argc, const char * argv[]) {// insert code here...std::cout Hello, World!\n;test1();int * p func();std::cout *p std::endl;std::cout *p std::endl;std::cout *p std::endl;std::cout *p std::endl;delete p;std::cout *p std::endl;return 0; }Hello, World! 10 10 10 10 -559071216 Program ended with exit code: 0 引用 给变量起别名 语法 数据类型 别名 原名 #include iostream #include mathutil.hpp #include string using namespace std; int main(int argc, const char * argv[]) {// insert code here...std::cout Hello, World!\n;int a 10;int b a;std::cout a a b b std::endl;b 100;std::cout a a b b std::endl;//引用必须初始化//int c;int d 20;b d; //赋值操作并不是更改引用std::cout a a b b d d std::endl;return 0; } 注意 引用必须要初始化 引用初始化后就不可以更改 引用做函数参数 作用 函数传参时可以利用引用的技术让形参修改实参 优点 可以简化指针修改实参 通过引用参数产生的 效果和按地址传递是一样的 引用的语法更清楚简单 // // main.cpp // cpplearn // // Created by KING on 2024/2/1. //#include iostream #include mathutil.hpp #include string using namespace std; void swapNum(int a,int b) {int temp a;a b;b temp; }void swapNum2(int* a,int* b) {int temp *a;*a *b;*b temp; } void swapNum3(int a,int b) {int temp a;a b;b temp; }int main(int argc, const char * argv[]) {// insert code here...std::cout Hello, World!\n;int a 10;int b 20;swapNum(a, b);std::cout a a b b std::endl;swapNum2(a, b);std::cout a a b b std::endl;swapNum3(a, b);std::cout a a b b std::endl;return 0; }引用做函数返回值 不要返回局部变量的引用 Reference to stack memory associated with local variable a returned #include iostream #include mathutil.hpp #include string using namespace std; int test03() {int a 10; /// 局部变量在栈区return a; } int main(int argc, const char * argv[]) {// insert code here...std::cout Hello, World!\n;int a test03();std::cout a a std::endl;return 0; }函数的调用可以作为左值 // // main.cpp // cpplearn // // Created by KING on 2024/2/1. //#include iostream #include mathutil.hpp #include string using namespace std; int test04() {static int a 10; /// 局部变量在栈区return a; } int main(int argc, const char * argv[]) {// insert code here...std::cout Hello, World!\n;int a test04();std::cout a a std::endl;std::cout a a std::endl;test04() 1000;std::cout a a std::endl;std::cout a a std::endl;return 0; }Hello, World! a10 a10 a1000 a1000 Program ended with exit code: 0 引用的本质 引用的本质在cpp中就是一个指针常量 常量引用 用来修饰形参防止误操作 // // main.cpp // cpplearn // // Created by KING on 2024/2/1. //#include iostream #include mathutil.hpp #include string using namespace std; void printNum(int num) {std::cout num std::endl;num 100; } void printNum2(const int num) {std::cout num std::endl;//num 100;//Cannot assign to variable num with const-qualified type const int }int main(int argc, const char * argv[]) {// insert code here...std::cout Hello, World!\n;// 引用必须引用一块合法的内存空间//int a 20;// 加上const 之后 这里相当于 编译器将代码修改为 int temp 10; const int ref temp;const int ref 10; // 加入const 之后变为只读不可以修改// 引用本质是指针常量 指针常量 特点是 不能修改指向 只能修改指针保存地址的值int num 22;printNum(num);std::cout num std::endl;int num2 20;printNum2(num2);return 0; }
http://www.pierceye.com/news/154526/

相关文章:

  • 用自己服务器做网站用备案wordpress弹窗订阅
  • 配色相关网站省住房城乡建设厅网站
  • 做汽车配件出口用什么网站好些求百度关键词搜索网站
  • 做网站到八方资源网怎么样公司网站首页如何做
  • 东莞政务网站建设方案wordpress三栏博客主题
  • 艺友网站建设网站需要的栏目
  • 教育类网站 前置审批重庆网站建设首选卓光
  • 宁波做网站哪家好个人做论坛网站怎么做
  • 公司网站建设北京电子设计工程期刊
  • 网站前端建设都需要什么c 网站开发案例详解
  • 无锡网站无忧网站建设
  • 最火高端网站设计厂家宁波新亚建设内部网站
  • 娱乐网站建设宁波网站建设多少钱一年
  • app制作器手机版下载网站关键词优化排名怎么做
  • 网站站外优化推广方式网站建设网站需要什么软件有哪些
  • 重庆建设厂招聘信息网站做坑网站需要
  • 光谷 网站建设公司海珠区住房和水务建设局网站
  • 公司做网站还是做appwordpress多文件传递变量
  • 网站教学苏州优化网站
  • 扁平化网站下载网站设计公司深圳
  • flash网站用什么做网站建设免费软件有哪些
  • 卖车网站投资网站建设
  • 网站开发过程 文档合肥婚恋网站建设
  • 网站自助建设目录更新 wordpress
  • 百度给做网站吗flash网站制作教程 下载
  • 化工销售怎么做网站wordpress 论坛功能
  • 网上做平面设计兼职不错的网站网站 seo优化
  • seo做的最好的网站设计专业
  • 顾家家居网站是哪个公司做的东莞软件有限公司
  • 云南做网站哪家好wordpress文章内多页效果