zoukankan      html  css  js  c++  java
  • typedef C++ 和C的不同之处

    首先结构体是C语言中首次提出来的其标准写法是

     1 typedef struct newStructName{
     2 int a;
     3 
     4 }S;//这个S是可以任意起名字的
     5 //这里面 Struct nameStructName 和 后面定义的S是等价的
     6 //c语言中是必须要用typedef的
     7 
     8 
     9 ————————————————————————————————————
    10 //换另一种写法
    11 typedef struct{
    12 int a;
    13 }S;
    14 //这种就是声明了一个S的结构体 但是就不能用上述方法用另一种代替了

    而到了C++中,其对struct结构体的声明并不需要用typedef;

    1 //在C++中 结构体的定义可以这么写:
    2 struct StructName{
    3 int a;
    4 }s;//这里的s已经不是类型了,而是一个StructName 类型的变量 
    5 //如果想把S当做类型,还得需要用typedef
  • 相关阅读:
    动画02
    动画01
    css过渡
    06强制类型转换
    05强制类型转换
    jetson 安装opencv4.4.0
    cpp中的内置异常
    cpp中std::string和std::wstring 相互转换
    qt creator杂记
    win10 git bash 使用vim 显示 git log
  • 原文地址:https://www.cnblogs.com/moonandwhite/p/7614389.html
Copyright © 2011-2022 走看看