Main must return int error in C + +?

Source: Internet
Author: User

The tempera trun to the Huashi C:

#include "iostream"

using namespace Std;

Class Tempera
{
Public
float cels;
Float Change ()
{
Return (9*cels)/5+32;
}
};

void Main ()
{
Tempera C;
cout << "Enter Celsius temperature value:" <<endl;
CIN >>c.cels;
cout << "Convert to Fahrenheit temperature:" << c.change () << "degrees" <<endl;

.........................................................................................................................

I used the "g++ to build", it always says "main must retrun int".

bd@bd-desktop:~/documents$ g++-O tempera tempera.cpp
Tempera.cpp:17:error: ':: Main ' must return ' int '
bd@bd-desktop:~/documents$

It should be ' int main () ' instead of ' void main (void) and then put a ' return 0 ' at the ' end of the ' function.

It's not a program problem, it's a compiler problem.

This is the standard of C language, and Dev C + + strictly comply with this rule.
The DOS version of Turbo C 3 does not conform to the language standard, and it does not mean that it is correct.

(Note: The main front must be int, since main is preceded by an int so the main function must have a return statement)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.