C++编译器错误c4430"c ++不支持默认int"

Reh*_*qvi 6 c++ int alias typedef

您好我试图定义一个名为USHORT的别名.

    // *****************
// Demonstrates typedef keyword
#include <iostream>

typedef unsigned short int USHORT;  // typedef defined

main()
{
USHORT  Width = 5;
USHORT Length;
Length = 10;
USHORT Area  = Width * Length;
std::cout << "Width:" << Width << "\n";
std::cout << "Length: "  << Length << std::endl;
std::cout << "Area: " << Area;
}
Run Code Online (Sandbox Code Playgroud)

我一直收到编译错误说:

错误1错误C4430:缺少类型说明符 - 假定为int.注意:C++不支持default-int c:\ users \naqvi-home\documents\justit\c ++\w1\cp1\list0304.cpp 8 1 ConsoleApplication3

谢谢

射线

Jos*_*eld 11

它与你的无关typedef.问题是你还没有给出一个返回类型main:

int main()
{
  // ...
}
Run Code Online (Sandbox Code Playgroud)

函数必须具有返回类型.该main函数必须返回int.