1

This is the class "Date.h"

class Date
{
    private: 
        int day;
        int month;
        int year;

    public:         
        void PrintDateV2();
        Date(int, int, int);
        ~Date();

};

This is "Date.cpp" with the implementation of the specified function that doesnt work

void Date::PrintDateV2()
{
    string months[12]={"January", "February", "March", "April", "May", "June", "July",           "August", "September", "October", "November", "December"};
   /*line of error*/cout << months[month-1] << endl;//<< ":: " << day << ", " << year << endl;
}

this is the error in visual studio in error list:

no operator "<<" matches these operands operand types are: std::basic_ostream char, std::char_traits> << std::string

billz
  • 44,644
  • 9
  • 83
  • 100
yshikita
  • 23
  • 4

1 Answers1

3

You forgot

#include <string>

in your program before using operator<<.

Platinum Azure
  • 45,269
  • 12
  • 110
  • 134
Kal
  • 1,309
  • 11
  • 16
  • @jxh i try to let content stand on its own insted of relying of presentation to get upvotes – Kal Oct 07 '13 at 03:00
  • Meh. I see it as rewarding for a correct answer. But good point-- I should get some credit for fixing the answer. – Platinum Azure Oct 07 '13 at 03:00
  • @Kal: I don't know... it seems more like you're just trying to get an early, quick answer without paying the cost of four extra characters. If that's not upvote scamming, what is? ;-) – Platinum Azure Oct 07 '13 at 03:01
  • @Kal: Both are important, because a clear presentation is a clear answer. – jxh Oct 07 '13 at 03:05