CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: complier error

  1. #1
    Join Date
    Sep 2009
    Posts
    12

    complier error

    Code:
    #include "stdafx.h"
    #include <iostream>
    #include <ctime>
    
    using namespace std;
    
    string randWord();
    
    int main()
    {
    
    	string guessWord = randWord(); //sets the returning value in guessWord
    
    	cout << guessWord;             //displays the random word
    
    	return 0;
    }
    
    string randWord()
    {
    	string wordBankArray[3] = {"random", "words", "here"};
    
    	srand(static_cast<int>(time(0)));
    	int randWord = rand() % (2 + 1);
    
    	return wordBankArray[randWord];
    }
    I'm getting this complier error.
    Code:
    1>------ Build started: Project: Hangman Project, Configuration: Debug Win32 ------
    1>Compiling...
    1>Hangman Project.cpp
    1>c:\documents and settings\angel\desktop\random\random project\random project.cpp(16) : error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: complier error

    #include <string>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured