Why will cout not print this std::string?
Jan 7, 2015 at 12:36pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
#include <iostream>
struct WeatherStats
{
double total_rainfall;
int high_temp;
int low_temp;
int avg_temp;
};
WeatherStats getWeatherData(std::string);
const int MONTHS = 12;
int main()
{
std::string month_names[MONTHS] = { "January" , "February" , "March" , "April" , "May" , "June" ,
"July" , "August" , "September" , "October" , "November" , "December" };
WeatherStats monthly_weather_data[MONTHS];
for (int count = 0; count < MONTHS; count++)
{
monthly_weather_data[count] = getWeatherData(month_names[count]);
}
}
WeatherStats getWeatherData(std::string month)
{
std::cout << "\t\t\tWeather Data for " << month << std::endl;
}
The function getWeatherData will not print the argument std::string month and it says "no operator "<<" matches these operands." I don't know what I'm doing that's illegal but I'm new to C++ so please help me. I've underlined "month" in the same place it's underlined in my compiler.
Jan 7, 2015 at 12:43pm UTC
did you #include <string>
?
Jan 7, 2015 at 12:49pm UTC
kill me now -_-
Topic archived. No new replies allowed.