zoukankan      html  css  js  c++  java
  • [C++] 用Xcode来写C++程序[3] Constants

    用Xcode来写C++程序[3] Constants

    以下是一些基本数据的含义:

    75         // int
    75u        // unsigned int
    75l        // long
    75ul       // unsigned long 
    75lu       // unsigned long 
    3.14159    // 3.14159
    6.02e23    // 6.02 x 10^23
    1.6e-19    // 1.6 x 10^-19
    3.0        // 3.0  
    3.14159L   // long double
    6.02e23f   // float  
    'z'        // 单个字符
    "How do you do?"  // 字符串


    一些符号的含义:


    bool类型以及指针
    bool foo = true;
    bool bar = false;
    int* p = nullptr;


    const变量
    #include <iostream>
    using namespace std;
    
    const double pi = 3.14159;
    const char newline = '
    ';
    
    int main ()
    {
      double r=5.0;               // radius
      double circle;
    
      circle = 2 * pi * r;
      cout << circle;
      cout << newline;

    宏定义:

    #include <iostream>
    using namespace std;
    
    #define PI 3.14159
    #define NEWLINE '
    '
    
    int main ()
    {
      double r=5.0;               // radius
      double circle;
    
      circle = 2 * PI * r;
      cout << circle;
      cout << NEWLINE;
    
    }

     

  • 相关阅读:
    《构建之法》第四章的感悟
    单复利软件单元测试
    实验一 操作系统模仿cmd
    <构建之法>第一二三章感悟
    近期工作量统计
    复利计算3.0
    复利运算
    单利运算1
    复利计算6.0
    汉堡包
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/4316667.html
Copyright © 2011-2022 走看看