Compile your own C ++ header file

Source: Internet
Author: User

// 9_1.cpp: defines the entry point of the console application.
//

// Define the coodin header file
# Ifndef coordin_h _
# Define coordin_h _
Struct polar
{
Double distance;
Double angle;
};
Struct rect
{
Double X;
Double Y;
};
Polar rect_to_polar (rect xypos );
Void show_polar (polar dapos );
# Endif

9_1_2 File

# Include "stdafx. H"
# Include <iostream>
# Include <cmath>
# Include "coordin. H"
Polar rect_to_polar (rect xypos)
{
Using namespace STD;
Polar answer;
Answer. Distance = SQRT (xypos. x * xypos. x + xypos. y * xypos. y );
Answer. angle = atan2 (xypos. Y, xypos. X );
Return answer;
}
Void show_polar (polar dapos)
{
Using namespace STD;
Const double red_to_deg = 57.29577951;
Cout <"distance =" <dapos. distance;
Cout <", angle =" <dapos. Angle * red_to_deg;
Cout <"Degrees \ n ";
}

9_1 File

// 9_1.cpp: defines the entry point of the console application.
//

# Include "stdafx. H"
# Include <iostream>
# Include "coordin. H"
Using namespace STD;

Int _ tmain (INT argc, _ tchar * argv [])
{
Return 0;
}
Int main ()
{
Rect rplace;
Polar pplace;
Cout <"Enter the X and Y value :";
While (CIN> rplace. x> rplace. Y)
{
Pplace = rect_to_polar (rplace );
Show_polar (pplace );
Cout <"next two numbers (Q to quit ):";
}
Cout <"Bye! \ N ";
Return 0;
}

 

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.