Can some explain to me (C++ newbie) why the following code compiles and runs fine using g++ on linux but always returns a value of 0 when compiled with DevShed on an XP box? I'm assuming it has to do with the compiler and not the platform, am I correct?
****************************
// Include statements
#include <iostream>
using namespace std;
// function prototypes.
float cube_number(float num);
int main()
{
float number;
float number4;
cout << "Please enter a number \n";
cin >> number;
number4 = cube_number(number);
cout << number << " cubed is " << number4;
return 0;
}
float cube_number(float num)
{
// this function simply takes a number, cubes it,
// then returns the answer
float answer;
return answer;
}
***************************************
Thx,
FM
****************************
// Include statements
#include <iostream>
using namespace std;
// function prototypes.
float cube_number(float num);
int main()
{
float number;
float number4;
cout << "Please enter a number \n";
cin >> number;
number4 = cube_number(number);
cout << number << " cubed is " << number4;
return 0;
}
float cube_number(float num)
{
// this function simply takes a number, cubes it,
// then returns the answer
float answer;
return answer;
}
***************************************
Thx,
FM