While Loop Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • d0ugg
    New Member
    • Jan 2007
    • 41

    While Loop Problem

    Hi all,

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

    error C2784: 'std::basic_ost ream<_Elem,_Tra its> &std::operat or <<(std::basic_o stream<_Elem,_T raits> &,const std::basic_stri ng<_Elem,_Trait s,_Alloc> &)' : could not deduce template argument for 'std::basic_ost ream<_Elem,_Tra its> &' from 'std::istream'
    see declaration of 'std::operator <<'

    Here is the main part of my project.

    Code:
    #include <iostream>
    #include <String>
    #include <fstream>
    #include "BTree.h"
    using namespace std;
    
    int Check(double Z);								//First Number Selected
    
    
    int main()
    {
    
    	cout << "\tWelcome to Binary Tree Sorting Program" << endl;
    	cout << "\nInput integers will be sorted." << endl;
    	
    
    	char symbol;
    	BTree T;										//establish BTree class
    	int Input;										//variable Insert
    
    	while(true)
    	{
    		cout << "\nPress I to input integers" << endl;
    		cout << "\nPress D to display the list" << endl;
    		cout << "\nPress E to exit the program" << endl;
    		cout << "-> ";
    		cin << symbol;
    		cout << endl;
    
    	
    	switch(symbol)
    	{
    	case 'I':
    	case 'i':
    		for(int i=0;;i++)
    		{												//loop until break called
    			cout << "Insert number (Q to quit)";		//user interface
    			cin >> Input;								//user input
    
    			if(Input == -1)								//declare if break
    				exit(0);								//break the loop
    			if(Check(i))								//check if 1st input
    				T.FInsert(Input);						//call FInsert
    			else										//otherwise:
    				T.Put(Input);							//call normal Put
    		}
    		break;
    
    	case 'D':
    	case 'd':
    			cout << "Displaying the list" << endl;
    			cout << endl;
    			T.Put(Input);
    			break;
    			
    	case 'E':
    	case 'e':
    		if(symbol == 'e' || symbol == 'E')					//If the user press E or e, program terminates
    				exit(0);
    	}
    	}
    	return 0;
    }
    
    
    int Check(double Z)
    {
    	if(Z==0)
    		return 1;
    	else
    		return 0;
    };
    Thanks for the help,

    Doug
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    Hi,
    You have a minor issue.
    [code=cpp]
    cout << "\nPress E to exit the program" << endl;
    cout << "-> ";
    // cin << symbol; I have commented this
    //it shuld be
    cin>>symbol;
    cout << endl;
    [/code]

    Raghuram
    Last edited by gpraghuram; Nov 28 '07, 03:44 AM. Reason: Typo error

    Comment

    Working...