By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,353 Members | 1,555 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,353 IT Pros & Developers. It's quick & easy.

While Loop Problem

P: 41
Hi all,

I have a little question, my compiler is giving me the following error:

error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
see declaration of 'std::operator <<'

Here is the main part of my project.

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <iostream>
  3. #include <String>
  4. #include <fstream>
  5. #include "BTree.h"
  6. using namespace std;
  7.  
  8. int Check(double Z);                                //First Number Selected
  9.  
  10.  
  11. int main()
  12. {
  13.  
  14.     cout << "\tWelcome to Binary Tree Sorting Program" << endl;
  15.     cout << "\nInput integers will be sorted." << endl;
  16.  
  17.  
  18.     char symbol;
  19.     BTree T;                                        //establish BTree class
  20.     int Input;                                        //variable Insert
  21.  
  22.     while(true)
  23.     {
  24.         cout << "\nPress I to input integers" << endl;
  25.         cout << "\nPress D to display the list" << endl;
  26.         cout << "\nPress E to exit the program" << endl;
  27.         cout << "-> ";
  28.         cin << symbol;
  29.         cout << endl;
  30.  
  31.  
  32.     switch(symbol)
  33.     {
  34.     case 'I':
  35.     case 'i':
  36.         for(int i=0;;i++)
  37.         {                                                //loop until break called
  38.             cout << "Insert number (Q to quit)";        //user interface
  39.             cin >> Input;                                //user input
  40.  
  41.             if(Input == -1)                                //declare if break
  42.                 exit(0);                                //break the loop
  43.             if(Check(i))                                //check if 1st input
  44.                 T.FInsert(Input);                        //call FInsert
  45.             else                                        //otherwise:
  46.                 T.Put(Input);                            //call normal Put
  47.         }
  48.         break;
  49.  
  50.     case 'D':
  51.     case 'd':
  52.             cout << "Displaying the list" << endl;
  53.             cout << endl;
  54.             T.Put(Input);
  55.             break;
  56.  
  57.     case 'E':
  58.     case 'e':
  59.         if(symbol == 'e' || symbol == 'E')                    //If the user press E or e, program terminates
  60.                 exit(0);
  61.     }
  62.     }
  63.     return 0;
  64. }
  65.  
  66.  
  67. int Check(double Z)
  68. {
  69.     if(Z==0)
  70.         return 1;
  71.     else
  72.         return 0;
  73. };
  74.  
  75.  
  76.  
Thanks for the help,

Doug
Nov 28 '07 #1
Share this Question
Share on Google+
1 Reply


gpraghuram
Expert 100+
P: 1,275
Hi,
You have a minor issue.
Expand|Select|Wrap|Line Numbers
  1.  cout << "\nPress E to exit the program" << endl;
  2.         cout << "-> ";
  3. //        cin << symbol; I  have commented this
  4. //it shuld be
  5.          cin>>symbol;
  6.         cout << endl;
  7.  
Raghuram
Nov 28 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.