C++基础语法及第一个C++程序

Tips:
 1. 本人当初学习C/C++的记录。
 2. 资源很多都是来自网上,如有版权请及时告知!
 3. 可能会有些错误。如有看到,希望能指出,以此共勉!

目录

C++关键字

数据类型

变量类型

常量

 第一个C++程序


C++关键字

auto

double

inline

short

typeid

bool

dynamic_cast

int

signed

typename

break

else

long

sizeof

union

case

enum

mutable

static

unsigned

catch

explicit

namespace

static_cast

using

char

export

new

struct

virtual

class

extern

operator

switch

void

const

false

private

template

volatile

const_cast

float

protected

this

wchar_t

continue

for

public

throw

while

default

friend

register

true

 

delete

goto

reinterpret_cast

try

 

C++11 关键字共73个。

新增关键字:alignasalignofchar16_tchar32_tconstexprdecltypenoexceptnullptrstatic_assertthread_local

 

数据类型

基本类型:bool, char, int, float, double, void wchar_tchar16_tchar32_t

复合类型:结构体,公用体,枚举,数组,

修饰:signed, unsigned, short, long

typedef可以位已经有的类型取一个新的名字 

typedef int my_int;

变量类型

大小写敏感,必须以字母或下划线开头。

Lelf_values & Right_values

Lelf_values: 指向内存位置的表达式,左值可以出现在赋值号的左边或右边

Right_values: 指存储在内存中某些地址的数值。右值不能对其进行赋值操作,可以出现在赋值号的右边,但是不能出现在左边

 

常量

定义方法:#define const

#define identifier value // 定义在文件头,不需要用“;”结束

const type variable = value;

 第一个C++程序

#include<iostream>
using namespace std;  //启用标准命名空间

int main()    //main()函数,程序入口
{
    cout << "hello, world" << endl;
    return 0;    //结束
}

 *每条语句结束记得加“;”哦。

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值