G
Gary Wessle
Hi
I am getting the warning below.
****************************************************************
cd ~/toy/
make -k
g++ -gdwarf-2 -c -o my.o my.cpp
my.cpp: In function ‘int main()’:
my.cpp:7: warning: converting to ‘int’ from ‘double’
g++ -Wall -gdwarf-2 -o proj my.o -lboost_filesystem -lboost_thread -L.
Compilation finished at Mon Jan 29 08:03:34
****************************************************************
the code is
****************************************************************
#include <iostream>
using namespace std;
int main(){
double b = 0.04;
int a;
a *= b;
cout << a << endl;
}
****************************************************************
do I leave the compiler to do the conversion or should I
static_cast<double> (a) before a *= b?
then
static_cast<int> (a) again when finished?
too much work...
thanks
I am getting the warning below.
****************************************************************
cd ~/toy/
make -k
g++ -gdwarf-2 -c -o my.o my.cpp
my.cpp: In function ‘int main()’:
my.cpp:7: warning: converting to ‘int’ from ‘double’
g++ -Wall -gdwarf-2 -o proj my.o -lboost_filesystem -lboost_thread -L.
Compilation finished at Mon Jan 29 08:03:34
****************************************************************
the code is
****************************************************************
#include <iostream>
using namespace std;
int main(){
double b = 0.04;
int a;
a *= b;
cout << a << endl;
}
****************************************************************
do I leave the compiler to do the conversion or should I
static_cast<double> (a) before a *= b?
then
static_cast<int> (a) again when finished?
too much work...
thanks