有人可以向我指出为什么此代码可能无法正常工作吗?我是C ++的新手,所以请保持谦虚!
这是我的main.cpp:
#include <iostream>
#include "fns.hpp"
int main() {
std::cout << "Hello! Would you like to convert into pounds or dollars?\n";
std::cin >> string;
std::cout << "Please type in the amount!\n";
std::cin >> number;
std::cout << calculation << "\n";
}
这是我的功能。cpp:
int calculation(std::string string, int number) {
if (string=="dollars") {
number == number * 0.5;
return number;
}
else if(string=="pounds") {
number == number * 2;
return number;
}
else{
return "Invalid!\n";
}
}