?
Solved

C++ Error in COde :  binary '<<' : no operator defined ... ( fast )

Posted on 2003-03-07
1
Medium Priority
?
717 Views
Last Modified: 2010-10-05
Hi experts
here is my code
need your help
verry importand and urgent

#include "stdafx.h"
#include <iostream.h>
#include <stdlib.h>
#include <string>
#include <fstream>
#include <stdio.h>
using namespace std ;

class Dictio {
private:
Dictio *a[26];
bool FlagEndWord;

public:
 void InsertWord(string wordToInsert);
 bool VerifyWord(string wordToVerify);
 Dictio();
 ~Dictio();
 void printAll(string prefix);
 void BuildDictio(string fname);
};

void Dictio::printAll(string prefix) {
 if (FlagEndWord) {
   cout << prefix << endl; //ERROR HERE
 for (char ch = 'A'; ch <= 'Z'; ++ch) {
   if (a[ch - 'A'] != NULL) // if there are words down thsi way
     a[ch - 'A']->printAll(prefix+ch);
}
}
}

void Dictio::BuildDictio(string fname) {
    ifstream fin;
   // open input stream fin on file fname
   string nextWord;
   while (fin >> nextWord) {
     // NOW we need to insert the word into this dictionary
   
     InsertWord(nextWord);
   }
   fin.close();
 }


int main()
{
 string fname;
 Dictio D;

 // get fname from the user (or from the command-line if you use
 
D.BuildDictio(fname);
 string word;
 
 while ((cin >> word) && (word != "done"))  // ERROR HERE
 {
   
      if (word == "dump")
      {
     
           D.printAll("");
      }
           else if (D.VerifyWord(word))
           {
                cout << word << " is VERIFIED!" << endl;
           }
               
           else
                     
                cout << word << " could not be verified." << endl;
           }
}




the problem they give me 3 errors :

C:\Comeonne\Comeoone.cpp(34) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversion)

C:\Comeonne\Comeoone.cpp(67) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversion)

C:\Comeonne\Comeoone.cpp(67) : fatal error C1903: unable to recover from previous error(s); stopping compilation

one more thing
i'm not able to make this part of the code :
void InsertWord(string wordToInsert);

So InsertWord takes a word (or part of a word) and inserts it into the dictionary. It does this by extracting the first letter from the word (if there is one) and checking the appropriate index in a. If that index is NULL create a new entry there. Now call InsertWord in the Dictio IN THAT INDEX (there either was one or we created one) with the TAIL of the word we are  inserting. That is, to insert JOE we call InsertWord four times:
 D.InsertWord("JOE");
 D.a['J'-'A']->InsertWord("OE");
 D.a['J'-'A']->a['O'-'A']->InsertWord("E");
 D.a['J'-'A']->a['O'-'A']->a['E'-'A']->InsertWord("");


if someone can just do this part and help me with the 3 erros, it would be amazing
i just cant make it work, and i dont have any time left
really appreciate any kind of help
0
Comment
Question by:Totto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 9

Accepted Solution

by:
tinchos earned 120 total points
ID: 8090649
try using

#include <iostream>

instead of

#include <iostream.h>
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question