//void FucTest(double Radius, double Height = 0)
void FunTest(double Radius, double Height)
{
using std::cout;
using std::endl;
if(Height == 0.0)
{
cout<<"This is a Sphere."<<endl;
cout<<"The Volume of the Sphere is : "<<4*Pi*Radius*Radius*Radius/3.0;
}else{
cout<<"This is a Cylinder."<<endl;
cout<<"The Volume of the Cylinder is : "<<Pi*Radius*Radius*Height;
}
}
//重载
/*
* OverLoading.cpp
*
* Created on: 2014年6月9日
* Author: John
*/
#include<iostream>
#include<string.h>
const int Pi = 3.14;
double CalcVolume(double Radius);
double CalcVolume(double Radius, double Height);
int main()
{
using std::cin;
using std::cout;
using std::endl;
using std::string;
double Radius = 0;
double Height = 0;
cout<<"Enter ‘s‘ for Sphere, ‘c‘ for Cylinder:"<<endl;
string str;
cin>>str;
cout<<"Enter Radius : ";
cin>>Radius;
if(str == "s" || str == "S")
{
cout<<"The Volume of the Sphere is : "<<CalcVolume(Radius)<<endl;
}
if(str == "c" || str == "C"){
cout<<"Enter Height : ";
cin>>Height;
cout<<"The Volume of the Cylinder is : "<<CalcVolume(Radius,Height)<<endl;
}
return 0;