【C++】重拾C++之数据类型与表达式

来源:互联网 发布:机器人编程需要学什么 编辑:程序博客网 时间:2024/05/22 17:45

写在前面的

   自从看了Ubisoft的一些职位信息之后,觉得自己的水平和他们的要求简直是天壤之别,所以觉得该是时候烤烤自己了,拿起N久没有看过的C++,不说了,直接上。

数据类型

  • 字符集
  • 基本数据类型
    • BOOL
    • CHAR
    • INT (int; signed; unsigned; short; long; unsigned short; unsigned long;) ——>Default
    • FLOAT (float\double\long double) ——>Default
  • 数值
    • 八进制 0
    • 十六 0x
    • 长整 L,l
    • 无符号 U,u
    • 无符号长整 Lu,lU ( LU/UL)
    • 浮点型 E
    • 字符数 \n,\t(ASCII—\xxx)
    • 字符串 字符由”
      字符串由”“
    • 布尔 0-false
    • 变量
  • 关键字
    定义与赋值(注意内存图问题)

  • 常量 可读性可维护性差
    符号常量
    #define 符号常量名 数值

  • 常变量
    const 数据类型 符号常量名 = 数值
    可换位置

  • 运算符与表达式

    • .1.优先级与结合性(左、右结合)

    • .2.算术运算符
      %—> MOD
      /—>两个整数,保留整数部分
      有一个浮点,通常意义的运算

    • .3.关系运算
      !=不等于
      ==等于

    • .4.逻辑运算符
      !取反 2
      &&与 12
      ||或 13 (短路运算)

    • .5.位运算符
      ~ 位求反
      << 左移
      >> 右移
      & 位与
      ^ 位异或
      | 位或

    • .6.赋值运算符
      *=……a=a*b
      <<=
      ……
      同样具有左右结合性

    • .7.++、–运算符
      后置 i++ 从左向右 1 x=i++ 先把I给X然后自加
      前置 –j 从右向左 2 x=++i 先自加后把I给X
      不能用作常量和表达式
      5++ (x+y)++

    • .8.其他运算符
      ..1.条件运算符:唯一一个三目运算符
      d1 ? d2 : d3
      true false
      ..2. 逗号运算符
      分隔
      ..3.字节运算符 sizeof

      ..4.成员运算符
      [ ]
      ..5.取址运算符 即变量A在内存中被分配的内存地址值
      & —-> & 变量值
      ..6.取指针内容运算符
      符号:*
      int a=5
      int *p=&a
      *p取出a存放于内存单元的值5.
      ..7.括号运算符
      ..8.运算符优先级的规律
      ..9.表达式的使用

    • 9.类型转换
      .1.自动转换(类似于VB的隐式转换)
      .2.强制类型转换
      类型说明符(表达式)

      (类型说明)表达式
      8.表达式的副作用
      不同编译器对2目运算编译有不同的做法,导致结果出现偏差

总结

   最后就用他们的招聘要求来结束这次的总结吧!
Responsibilities:
- Analyze and understand the AI needs from the creative director and game designers in terms of informatics development and assess the technical feasibility;
- Analyze existing AI features in the engine and see if they are suitable in light of the intentions;
- Whenever necessary, suggest improvements by designing and implementing new systems or modifying existing systems;
- Collaborate with designers to discuss constraints and set out the technical possibilities for the various AI features;
- Suggest innovations inspired by other games;
- Program in a clear and structured way, keeping in mind the performance, memory, maintenance, extensibility and compatibility requirements;
- Validate and verify that the newly developed systems meet the AI intentions of the project and are coherent with the existing code and optimize the systems whenever necessary;
- Work iteratively and involve designers when implementing new features;
- Work with other working units (design, animation) to develop the tools required to efficiently adjust AI systems;
- Support the AI features and systems designed for production;
- Determine and fix the AI bugs detected by the production and quality control teams;
- Document the work to share knowledge and enable users (programmers and users from other units) to understand how to use the new AI systems and features;

原创粉丝点击