如何更好的理解const限定符?
有一段简单的C++程序:#include<iostream>
int main()
{
using namespace std;
cout.setf(ios_base::fixed,ios_base::floatfield); //fixed-point
float tub=10.0/3.0; //good to about 6 places
double mint=10.0/3.0; //good to about 15 places
const float million=1.0e6;
cout<<"tub= "<<tub;
cout<<",a million tub= "<<million*tub;
cout<<",\nand ten million tubs= ";
cout<<10*million*tub<<endl;
cout<<"mint= "<<mint<<" and a million mints= ";
cout<<million*mint<<endl;
return 0;
}
问题1:为什么使用const?
问题2:a million tubs为什么=3333333.250000??