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

网站建设流程方案求职网站网页模板下载

网站建设流程方案,求职网站网页模板下载,域名自动更新中,二次开发主题wordpress字符串 字符串#xff0c;本质上是一个接一个字符的一组字符。字母、数字、符号等。 const char* 字符串名 字符后面会有一个空终止符#xff0c;为0。 字符串从指针的内存地址开始#xff0c;然后继续下去#xff0c;直到它碰到0#xff0c;然后意识到字符串终止了。 …字符串 字符串本质上是一个接一个字符的一组字符。字母、数字、符号等。 const char*  字符串名 字符后面会有一个空终止符为0。 字符串从指针的内存地址开始然后继续下去直到它碰到0然后意识到字符串终止了。 #include iostream int main() {const char* name Miles; //使用const之后就不能再改变该字符串的内容。//name[2] a;char name2[5] {M,i,l,e,s};std::cout name std::endl;std::cout name2 std::endl;std::cin.get(); } 为了使得代码更加简洁通常会引入string。 string中有一个构造函数它接收char*或const char*参数。 #include iostream #include string int main() {std::string name1 Miles;std::cout name1 std::endl;std::cin.get(); } std::string 是一个有很多功能的类。 name.size()可以找到其尺寸strlen()字符串的长度strcpy复制字符串 字符串相加可以考虑重载运算符“”。 #include iostream #include string int main() {std::string name1 Miles;name1 hello!;std::cout name1 std::endl;std::cin.get(); } //输出 //Miles hello! 字符串相加或者可以用另一种方法进行将两个相加的字符数组的其中一个显式调用一个string构造函数。相当于创建了一个字符串然后附加这个字符串给另一个。 #include iostream #include string int main() {std::string name1 std::string(Miles) hello!;std::cout name1 std::endl;std::cin.get(); } //输出 //Miles hello! 如果要寻找字符串中的文本可以使用name.find()。 #include iostream #include string int main() {std::string name1 std::string(Miles) hello!;bool contains name1.find(es) ! std::string::npos; std::cout name1 std::endl;std::cin.get(); } 其中std::string::npos代表一个不存在的位置。将结果给contains。 #include iostream #include string void PrintString(std::string string) {string h;std::cout string std::endl; } int main() {std::string name1 std::string(Miles) hello!;PrintString(name1);bool contains name1.find(es) ! std::string::npos; std::cout name1 std::endl;std::cin.get(); } //输出 //Miles hello!h //Miles hello! 需要分配一个全新的char数组来存储我们已经得到的完全相同的文本。 字符串复制实际上相当慢。 当我们需要传递一个字符串而且在只读的情况下需要确保通过常量引用传递它。此时通常在前面加上const和引用。 void PrintString(const std::string string) {//string h;std::cout string std::endl; } 字符串字面量 字符串字面量是在双引号之间的一串字符。 字符串后面有一个额外的字符叫做空终止字符。 #include iostream #include string#include stdlib.h int main() {const char name[7] Mi\0les;std::cout strlen(name) std::endl; //打印出字符串的长度。std::cin.get(); } 字符串的相加还能用到string_literals库。在字符串后面加上s即可实现字符串的相加。 #include iostream #include string #include stdlib.h int main() {using namespace std::string_literals;std::string name Miless hello!;std::cout name std::endl; std::cin.get(); } //输出 //Miles hello! 其中s实际上是一个函数。操作符函数它返回标准字符串对象。 R可以用来忽略转义字符。使得代码更加简洁。 #include iostream #include string#include stdlib.h int main() {const char* example R(Line1 line2 line3) ;//R忽略转义字符const char* ex Line1\nline2\nline3\n;std::cout example std::endl;std::cout ex std::endl;std::cin.get(); } 字符串字面量永远保存在内存的只读区域 关键字const 关键字 const称为伪关键字。因为它在改变生成代码方面做不了什么。有点像类和结构体的可见性。 #includeiostream #includestring int main() {const int MAX_AGE 90;std::cin.get(); } 在堆上建立一个整数就能得到一个指针。此时有两个方案 逆向引用dereference重新分配实际的指针这样会指向别的东西 用const强制定义一个变量为只读常量。但可以强制改变这个定义如下利用(int*)可以将const只读常量的值逆向引用传给另一个变量。 #includeiostream #includestring int main() {const int MAX_AGE 90;int* a new int;*a 2;a (int*)MAX_AGE;std::cout *a std::endl;std::cin.get(); } //输出 //90 但const int* 意味着不能修改指针指向的内容。该用法和int const*一致。 const int* a new int; int const* a new int; int* const可以改变指针指向的内容但不能把实际的指针本身重新赋值指向别的东西。 #includeiostream #includestring class Entity { private:int m_X, m_Y; public:int GetX() const //此用法只能读不能写。该方法只能进行读操作不能进行其他的修改操作。{return m_X;}void SetX(int x){m_X x;} }; int main() {const int MAX_AGE 90;int* a new int;*a 2;a (int*)MAX_AGE;std::cout *a std::endl;std::cin.get(); } 如果用再次复制Entity类的方式需要分配空间那样会很慢。可以通过常量引用传递的方式。也就是const Entity e #includeiostream #includestring class Entity { private:int m_X, m_Y; public:int GetX() const{return m_X;}void SetX(int x){m_X x;} }; void PrintEntity(const Entity e) {std::cout e.GetX() std::endl; //由于GetX()用到了const才能在这里用到e.GetX() } int main() {const int MAX_AGE 90;int* a new int;*a 2;a (int*)MAX_AGE;std::cout *a std::endl;std::cin.get(); } 如果要对int GetX() const中的变量进行修改的话可以引入mutable #includeiostream #includestring class Entity { private:int m_X, m_Y;mutable int var; public:int GetX() const{var 2;return m_X;}void SetX(int x){m_X x;} }; mutable允许函数是常量的方法可以修改变量。 关键字mutable mutable的两种不同用途 与const一同使用。用在lambda表达式中。 或者mutable可以同时覆盖两种情况。 #include iostream #include string class Entity { private:std::string m_Name;mutable int m_DebugCount; public:const std::string GetName() const{m_DebugCount; //每次调用get的时候都会记一次数return m_Name;} }; int main() {const Entity e;e.GetName();std::cin.get(); } 在类成员中使用mutable。 lambda基本上像一个一次性的小函数可以写出来并赋值给一个变量。 #include iostream #include stringclass Entity { private:std::string m_Name;mutable int m_DebugCount; public:const std::string GetName() const{m_DebugCount; return m_Name;} }; int main() {const Entity e;e.GetName(); //lambda的使用如下int x 8;auto f [](){x;std::cout x std::endl;};f();std::cin.get(); }lambda还有其他的用法三种auto用法一致。 int x 8; auto f []() {x;std::cout x std::endl; }; auto f []() mutable {x;std::cout x std::endl; }; auto f []() {int y x;y;std::cout x std::endl; }; f();
http://www.hkea.cn/news/14377626/

相关文章:

  • 山东企业网站建设费用群晖 wordpress 迁移
  • 淘宝联盟网站建设不完整网站建设应用技术
  • 网站制作小工具腾讯企业qq
  • 江西网站建设哪家公司好广州新闻头条最新消息
  • 宽屏网站模板html有哪些网站结构是不合理的
  • 网站建设合同 域名seo怎么做
  • app开发和网站开发价格德惠市城乡建设局网站
  • 微信官网网站门面商铺装修
  • 网站app建站多少钱优酷的网站头怎么做的
  • 网站模板和源码区别有哪些有趣的网站
  • 网站运作方式wordpress 搜索词
  • 网站流量查询服务平台海南酒店网站建设
  • 大网络公司做网站wordpress精致建站
  • 外国人做数学视频网站微信营销的方法
  • 网站建设新闻 常识企业网站seo成功案例
  • 离退休部门网站建设情况网站备案需要当面核验哪些信息
  • 深圳外贸网站开发公司wordpress动漫模板
  • 苏宁易购网站建设的目标如何创建企业邮箱
  • 360网站拦截做国外有什么优秀的网站推荐
  • 中国建设行业峰会官方网站信息网站设计方案
  • 营销型网站规划南京正规小程序开发公司
  • 专业的网站建设企业网站注册1000万公司需要多少钱
  • 国外外贸网站大全工程项目外包平台
  • 营销型 手机网站怎么用h5做网站
  • 手机版网站原理中山网页设计公司
  • 如何做关于橱柜网站中东跨境电商平台有哪些
  • 如何加强企业网站建设 论文624小时免费更新在线视频
  • 广州网站推广制作网站制作宣传
  • 申请一个免费的网站空间成都网站建设网站
  • 国内网站要备案开发一个视频网站要多少钱