2014-02-16 3 views
0

문자열 배열에서 요소를 인쇄하려고합니다. 오류가있는 곳의 주석을 달았습니다.문자열 배열 요소 인쇄하기 C++

얻기 오류 :

  1. IntelliSense: no operator "<<" matches these operands operand types are: 
    std::ostream << const std::string 
    
  2. error C2679: binary '<<' : no operator found which takes a right-hand operand 
    of type 'const std::string' (or there is no acceptable conversion) 
    

#include <iostream> 
using namespace std; 

int main() 
{ 
    int day = 5, year = 2015; 


    const string months[13] = { 0, "January", "February", "March", "April", 
           "May", "June", "July", "August", "September", 
           "October", "November", "December" }; 

    cout << months[5] << " " << day << ", " << year << endl; //the first << is the issue 
} 

답변

3

당신은, 당신은 <string>의 일부가 <iostream>에서 발견 된 것을 충분히 행운이 있었다하지 #include <string> 않았다 그래서 01을 선언 할 수 있습니다..

+0

감사합니다. 문자열을 추가 한 후에 다른 문제가 발생합니다. 디버그 어설 션이 실패하고 중단해야합니다. 왜 이런 일이 일어나는 지 아십니까? – reezolv

+0

또한, 중단에 대한 오류가 잘못된 널 포인터라고 말했다. – reezolv