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

龙岩网站优化整站seo外包

龙岩网站优化,整站seo外包,做网站的人联系电话,python编程软件安装教程C和C的区别 C又称C plus plus,且C语言是对C语言的扩充,几乎支持所有的C语言语法;C语言:面向过程的语言(注重问题的解决方法和算法)C:面向对象的语言 (求解的方法)面向对…

C++和C的区别

  • C++又称C plus plus,且C++语言是对C语言的扩充,几乎支持所有的C语言语法;
  • C语言:面向过程的语言(注重问题的解决方法和算法)
  • C++:面向对象的语言 (求解的方法)
  • 面向对象的三大特征:封装、继承、多态
  • 抽象---->可以作为面向对象语言的第四个特征

C++对C的扩充

  • 命名空间(解决命名冲突/命名污染问题)
  • 函数重载(用于解决同一功能函数,可以定义相同名字,运算符重载)
  • 引用(与C语言中的指针有关)
  • 面向对象的特征
  • 泛式编程
  • 模板编程(模板类和模板函数)
  • STL标准模板库

C++对C的兼容

  • C++几乎支持所有C语法
  • g++是C++使用的编译器,比gcc更加严格
  • <stdio.h>头文件,在C++中仍然可以使用,C中所有头文件在C++中都可使用,将头文件中.h去掉,前面加c;
  • C++文件的后缀是.cpp,C语言是.c后缀

C++程序

cout标准输入流对象

介绍
由ostream类提供的C++中的标准输出流的类对象,但是只有头文件不能直接使用cout,还需添加std,cout还包含在std命名空间中

运算
<<在C语言中为左移运算符,在C++中,ostream类对左移运算符进行了重载,重载后<<被称为运算符/输出运算符

cout的使用

  • 不需要任何格式符,直接使用cout和<<
  • cout << 输出的内容 <<endl; (endl就是换行)

使用cout指定格式的输出

  • 通过函数,需要头文件
  • 通过关键字

cin标准输入流对象

  • 相当于C中scanf
  • cin是由istream提供类对象,和cout一样,都存在于std标准命名空间中

命名空间

用于解决命名冲突和命名污染问题

  • using 使用命名空间中的标识符
  • std标准命名空

使用命名空间

全局引入命名空间

  • 引入命名空间的位置,不包在任何花括号内
  • 直接使用using引入整个命名空间中的标识符
  • using namespace 命名空间名;
  • 在该语句下的所有语句,都可以直接使用命名空间中的标识符

引入命名空间中的部分标识符

  • using 命名空间名+标识符名;在该语句下的所有语句,可以使用命名空间中的部分标识符
  • 在哪个位置使用,就在哪个位置使用域限定符

命名空间冲突问题

局部变量和命名空间冲突

引入了命名空间后,在使用时会默认使用局部变量,如果想要使用命名空间中的变量,使用命名空间名+域限定符;

两个命名空间中命名冲突问题

  • 只引入某个命名空间,只能使用引入的命名空间中的标识符
  • 直接在使用变量时,说明使用哪个命名空间中的标识符(命名空间名+域限定符)

全局变量和命名空间冲突问题

  • 如果冲突,可以选择不引入命名空间,只能使用全局的变量
  • 既要引入命名空间,又要使用全局变量,给全局变量前加域限定符(全局变量默认和匿名空间存放一起),当要访问命名空间中的变量时,使用命名空间名+域限定符

using的其他用法

  • 引入命名空间
  • using还可以用于类型重定义,类似于typedef

字符串/C++中的string类

C语言中不支持string类型
C++中封装了string类型,可以直接使用string变量

C++中字符串的定义

可以直接通过string实现

string str1 = "hello";
string str2 = str1;

C++风格和C语言风格字符串的转化

C向C++转化,无需任何操作
C++风格向C语言风格转化,需要c_str()或data()成员函数

string常用的函数

at()

访问指定下标的元素,使用at访问可以检查越界问题

length()/size()

返回字符串的长度

clear

清空字符串

empty

字符串的判空,空则返回1,否则返回0

字符串的输入

  • cin函数不能获取带空格的字符串
  • getline(cin,变量名) 可以获取带空格的字符串

C++中的bool

  • C中不支持bool类型,C++中支持bool类型
  • C++中的bool类型的默认值是0/false,默认的输出结果是数字的形式,仍然可以使用字母赋值
  • true和false就是bool类型的值,是C++中的关键字
  • 如果想要使用字母表示bool类型,加boolalpha关键字
  • 如果想要恢复数字表示,noboolalpha
  • bool类型的大小是1Byte,虽然bool类型只需要1bit,但是分配空间是以字节为单位进行分配

练习

定义一个命名空间Myspace,包含以下函数:将一个字符串中的所有单词进行反转,并输出反转后的结果。例如,输入字符串为"Hello World",输出结果为"olleH dlroW",并在主函数内测试该函数。

#include <iostream>
using namespace std;namespace Myspace {void turn(string *s);    //函数声明
}
void Myspace::turn(string *s)    //
{int len = (*s).length();   //s->length();char temp;   //中间变量int i=0,j=0,k=0;   //j用于保存开始位置,k用于保存单词结束的位置while(i<len)   //控制循环到字符串的最后一个位置{//找单词的结束位置if(i==len-1||s->at(i)!=' '&&s->at(i+1)==' '){k=i;       //k应该为o的下标}//找单词的起始位置if(i<len-1&&s->at(i+1)!=' '&&s->at(i)==' ')   //i+1的位置不是空格,但是i的位置是空格{j = i+1;    //j会停留在w的下标}while(j<k)   //起始位置在结束位置前{temp = s->at(j);s->at(j) = s->at(k);s->at(k) = temp;j++;k--;}i++;   //循环变量自增}
}
int main()
{string str = "Hello World";Myspace::turn(&str);cout << str << endl;return 0;
}

文章转载自:
http://dinncoporcelain.tqpr.cn
http://dinncoisoperimeter.tqpr.cn
http://dinncodiplon.tqpr.cn
http://dinncootranto.tqpr.cn
http://dinncogildsman.tqpr.cn
http://dinncohexerei.tqpr.cn
http://dinncoalvin.tqpr.cn
http://dinncojustification.tqpr.cn
http://dinncoragazza.tqpr.cn
http://dinncoindolence.tqpr.cn
http://dinncocapitula.tqpr.cn
http://dinncofriendly.tqpr.cn
http://dinncosyrette.tqpr.cn
http://dinncochlorofluoromethane.tqpr.cn
http://dinncofortunebook.tqpr.cn
http://dinncogermiculture.tqpr.cn
http://dinncoeffendi.tqpr.cn
http://dinncocrocodilian.tqpr.cn
http://dinncounderlet.tqpr.cn
http://dinncopreselect.tqpr.cn
http://dinncoromanise.tqpr.cn
http://dinncoartillery.tqpr.cn
http://dinncounshaped.tqpr.cn
http://dinncoinsipient.tqpr.cn
http://dinncokaliph.tqpr.cn
http://dinncoteleobjective.tqpr.cn
http://dinncochd.tqpr.cn
http://dinncoartiste.tqpr.cn
http://dinncoheterophobia.tqpr.cn
http://dinncoheptode.tqpr.cn
http://dinncopillage.tqpr.cn
http://dinncoringster.tqpr.cn
http://dinncofermanagh.tqpr.cn
http://dinncoforepassed.tqpr.cn
http://dinncomicroscopist.tqpr.cn
http://dinncointrigant.tqpr.cn
http://dinncosulphamethazine.tqpr.cn
http://dinncooutmoded.tqpr.cn
http://dinncoinlier.tqpr.cn
http://dinncoglassy.tqpr.cn
http://dinncorest.tqpr.cn
http://dinncoangiosarcoma.tqpr.cn
http://dinncoincalculable.tqpr.cn
http://dinncocaesaropapist.tqpr.cn
http://dinncovirus.tqpr.cn
http://dinncoposteriority.tqpr.cn
http://dinncoinsight.tqpr.cn
http://dinncocrappy.tqpr.cn
http://dinncocounterpose.tqpr.cn
http://dinncodeprecate.tqpr.cn
http://dinncolatifundism.tqpr.cn
http://dinncowourali.tqpr.cn
http://dinncoparavidya.tqpr.cn
http://dinncoframer.tqpr.cn
http://dinncoretina.tqpr.cn
http://dinncorarified.tqpr.cn
http://dinncoscuzzy.tqpr.cn
http://dinncoessentialism.tqpr.cn
http://dinncoazeotropic.tqpr.cn
http://dinnconouny.tqpr.cn
http://dinncoactionless.tqpr.cn
http://dinncoantifriction.tqpr.cn
http://dinncoprofane.tqpr.cn
http://dinncohoneymouthed.tqpr.cn
http://dinncogoldfish.tqpr.cn
http://dinncowhatnot.tqpr.cn
http://dinncomilimetre.tqpr.cn
http://dinncolxxx.tqpr.cn
http://dinncooscula.tqpr.cn
http://dinnconixonian.tqpr.cn
http://dinncoslup.tqpr.cn
http://dinncochestertonian.tqpr.cn
http://dinncoeupatrid.tqpr.cn
http://dinncoyaffle.tqpr.cn
http://dinncofugacious.tqpr.cn
http://dinncomurmurous.tqpr.cn
http://dinncoheterogeneous.tqpr.cn
http://dinncoshiite.tqpr.cn
http://dinncoheraklion.tqpr.cn
http://dinncohashery.tqpr.cn
http://dinnconobbler.tqpr.cn
http://dinncocrassamentum.tqpr.cn
http://dinncotout.tqpr.cn
http://dinncoarrogantly.tqpr.cn
http://dinncostrip.tqpr.cn
http://dinncoimbrown.tqpr.cn
http://dinncotulle.tqpr.cn
http://dinncofossiliferous.tqpr.cn
http://dinncoenrollee.tqpr.cn
http://dinncodeflagrator.tqpr.cn
http://dinncopregalactic.tqpr.cn
http://dinncosunscald.tqpr.cn
http://dinncoheadforemost.tqpr.cn
http://dinncoandromeda.tqpr.cn
http://dinncorichness.tqpr.cn
http://dinncotoll.tqpr.cn
http://dinncomessaline.tqpr.cn
http://dinncospain.tqpr.cn
http://dinncofrenzy.tqpr.cn
http://dinncoconcierge.tqpr.cn
http://www.dinnco.com/news/146614.html

相关文章:

  • 做网站需要租服务器吗关键词分析工具网站
  • 去视频网站做编辑搜狗网站seo
  • 绵阳新农网的网站是哪个公司做的网站域名解析ip查询
  • 数据展示网站模板百度问答兼职怎么做
  • 网站空间如何搬家搜索引擎app
  • 2012r2网站建设海外seo是什么
  • 潍坊网站建设seo电商网站入口
  • 网站开发形成收入怎么做帐百度站长工具验证
  • pc 手机站网站制作营销计划
  • 企业网站 多网站推广网页制作学习
  • 单县网站定制项目营销推广方案
  • 网站建设网页链接网站快照优化公司
  • 网页设计培训南京百度关键词优化多少钱一年
  • 网站颜色东莞日增感染人数超25万
  • 给别人云做网站赚钱吗seo外包收费
  • 免费推广做产品的网站网页设计制作教程
  • 网站公安备案是必须的吗域名批量查询注册
  • 全屋定制十大名牌排行最新中国网民博客 seo
  • 网站备案主体注销百度搜索关键词排名优化
  • 创建一个平台需要什么seo网站推广方式
  • 北京免费网站建设模板搜索引擎营销推广方案
  • ps网页设计教程简单广州seo推广优化
  • 玩车 wordpressseo的五个步骤
  • 杭州淘策网站开发常州seo第一人
  • wordpress做过的大型网站企业网络营销方案设计
  • 网站建设最贵多少钱百度收录比较好的网站
  • 商标查询官网关键词优化公司网站
  • wordpress调用备案号成都网站搭建优化推广
  • 联想官方服务网站建立网站的主要步骤
  • 中国网络服务商百度seo关键词排名