C Programming Write a mainfunction that declares several int

C++ Programming

Write a main()function that declares several integer, double, and City and Planet objects, and uses the calcDistance()function to compute the distance for several pairs. Save the file as Distance.cpp.

Solution

Here is the main() function for you:

main()
{
int pInt1, pInt2;
double pDouble1, pDouble2;
City pCity1, pCity2;
Planet pPlanet1, pPlanet2;
cout<<\"The distance between \"<<pInt1<<\" and \"<<pInt2<<\" is: \"<<calcDistance(pInt1, pInt2)<<endl;
cout<<\"The distance between \"<<pDouble1<<\" and \"<<pDouble2<<\" is: \"<<calcDistance(pDouble1, pDouble2)<<endl;
cout<<\"The distance between \"<<pCity1<<\" and \"<<pCity2<<\" is: \"<<calcDistance(pCity1, pCity2)<<endl;
cout<<\"The distance between \"<<pPlanet1<<\" and \"<<pPlanet2<<\" is: \"<<calcDistance(pPlanet1, pPlanet2)<<endl;
}

And remember you need a supporting calcDistance() method which support templates for this to work.

Also you need the classes City, and Planet for this code to work.

C++ Programming Write a main()function that declares several integer, double, and City and Planet objects, and uses the calcDistance()function to compute the di

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site