zoukankan      html  css  js  c++  java
  • C++学习笔记(1)

    1.编译 先把cpp文件编译
    2.组建 把编译好的文件组建成.exe 文件
    3 1).iostream 输入输出 头文件
      其中有两个对象
      cout 对象 << 运算符重载 用于输出
      cin  对象 >> 运算符重载 用于输入

      2).cmath 引用原始的c头文件 在其前面加个c 也可用 math.h
        double sqrt(double b) 求平方根的函数
        double pow(double a,double b) 求指数的 函数 pow(2,3) 求2的3次幂是多少
        int rand() 函数 随机函数
      3).climits c头文件 limits.h 的c++版本
      定义了符号常量 用来表示 类型的限制
      4).string 头文件
       定义了 string 类型
    4.
      数组中对数组下标错误 感觉处理的挺不好的不好
     #include<iostream>
     #
     int Arr[4] ={1,2,3,4};
     for(int i=0;i<8;i++)
     {
     cout << Arr[i] << endl;
     }
    5.Struct结构
     #include<iostream>
     #include<string>
     using namespace std;
     struct Guest
     {
     //string name;//执行失败 error C2552: 'g' : non-aggregates cannot be initialized with initializer list
     char mame[20];换成char 数组 执行成功 为什么 使用string类型不能成功呢?
     int age;
     };
     int main()
     {
     Guest g =
     {
      "QA龙",
      23
     };
     cout << g.name <<endl << g.age <<endl ;
     }
     执行失败
     原因:因为有些编译器(包括Borlandc++ 5.5 和7.0 版以前的Microsoft Visual C++)不支持以string 对象作为成员的结构进行初始化
          可以在结构定义之前 使用using指令 using namespace std; 让结构可以访问std空间
          但是如此以后 还是不能 像数组那样给结构赋值

    小弟主要学c# .net 的 刚开始学c++ 老多东西都不知道 请各位大仙多多指导

  • 相关阅读:
    javascript变量作用域、匿名函数及闭包
    SenchaTouch2中navigation下嵌入list无事件响应问题解决
    Fedora17安装SSH
    25个必须记住的SSH命令
    linux下安装hadoop
    Fedora17实现图形界面root登录
    virtualBox利用已创建的vdi文件克隆快速创建新虚拟机
    printf/scanf格式修饰符
    windowsServer2003服务器上修改ftp端口号
    为ckeditor添加行距的功能(转载)
  • 原文地址:https://www.cnblogs.com/liubaolongcool/p/2156429.html
Copyright © 2011-2022 走看看