• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 718
  • Last Modified:

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

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
Totto
Asked:
Totto
1 Solution
 
tinchosCommented:
try using

#include <iostream>

instead of

#include <iostream.h>
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now