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

Hybrid View

  1. #1
    Join Date
    Jun 2012
    Posts
    11

    [RESOLVED] Multiple Compparisons in one block help.

    here's my program bake.cpp(name does not reflect content) I've been researching this binary error and haven't been able to find a solution, so please help!

    Code:
    #include "stdafx.h"
    #include <iostream>
    #include <string>
    #include <conio.h>
    using namespace std;
    int main()
    {
    	//Display a list of options.
    	cout << "Choose your favorite:" << endl;
    	cout << "1. Apples " << endl;
    	cout << "2. Bananas " << endl;
    	cout << "3. Fried worms " << endl;
    	cout << "4. Poison Apples " << endl;
    	cout << "5. Lobster " << endl;
    	//Obtain the user's selection.
    	char ch = _getch();
    	//Continue getting user selections until the user enters a valid number.
    	while (ch < '1' || ch > '5')
    	{
    		ch = _getch();
    	}
    	//Use a switch to display the user's selection.
    	cout << "You choose " << ch << endl;
    	switch (ch) {
    	case '1':
    		cout << "Apples are good for you!" << endl;
    		break;
    	case '2':
    		cout << "Bananas have plenty of potassium!" << endl;
    		break;
    	case '3':
    		cout << "That's disgusting!" << endl;
    		break;
    	case '4':
    		cout << "All i wanna know is WHY?" << endl;
    		break;
    	case '5':
    		cout << "Expensive but good taste you have!" >> endl;
    		break;
    	}
    	system("pause");
    	return 0;
    }
    my error code..


    1>------ Build started: Project: bake, Configuration: Debug Win32 ------
    1> bake.cpp
    1>c:\users\jonbecher\documents\visual studio 2012\projects\bake\bake\bake.cpp(41): error C2784: 'std::basic_istream<_Elem,_Traits> &std::operator >>(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::basic_ostream<_Elem,_Traits>'
    1> with
    1> [
    1> _Elem=char,
    1> _Traits=std::char_traits<char>
    1> ]
    1> c:\program files\microsoft visual studio 11.0\vc\include\string(460) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\string(460) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\string(460) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\string(460) : see declaration of 'std::operator >>'
    1>c:\users\jonbecher\documents\visual studio 2012\projects\bake\bake\bake.cpp(41): error C2784: 'std::basic_istream<_Elem,_Traits> &std::operator >>(std::basic_istream<_Elem,_Traits> &&,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::basic_ostream<_Elem,_Traits>'
    1> with
    1> [
    1> _Elem=char,
    1> _Traits=std::char_traits<char>
    1> ]
    1> c:\program files\microsoft visual studio 11.0\vc\include\string(346) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\string(346) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\string(346) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\string(346) : see declaration of 'std::operator >>'
    1>c:\users\jonbecher\documents\visual studio 2012\projects\bake\bake\bake.cpp(41): error C2784: 'std::basic_istream<_Elem,_Traits> &std::operator >>(std::basic_istream<_Elem,_Traits> &&,_Ty &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::basic_ostream<_Elem,_Traits>'
    1> with
    1> [
    1> _Elem=char,
    1> _Traits=std::char_traits<char>
    1> ]
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1084) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1084) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1084) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1084) : see declaration of 'std::operator >>'
    1>c:\users\jonbecher\documents\visual studio 2012\projects\bake\bake\bake.cpp(41): error C2784: 'std::basic_istream<char,_Traits> &std::operator >>(std::basic_istream<char,_Traits> &,unsigned char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::basic_ostream<_Elem,_Traits>'
    1> with
    1> [
    1> _Elem=char,
    1> _Traits=std::char_traits<char>
    1> ]
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1074) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1074) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1074) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1074) : see declaration of 'std::operator >>'
    1>c:\users\jonbecher\documents\visual studio 2012\projects\bake\bake\bake.cpp(41): error C2784: 'std::basic_istream<char,_Traits> &std::operator >>(std::basic_istream<char,_Traits> &,unsigned char *)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::basic_ostream<_Elem,_Traits>'
    1> with
    1> [
    1> _Elem=char,
    1> _Traits=std::char_traits<char>
    1> ]
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1067) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1067) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1067) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1067) : see declaration of 'std::operator >>'
    1>c:\users\jonbecher\documents\visual studio 2012\projects\bake\bake\bake.cpp(41): error C2784: 'std::basic_istream<char,_Traits> &std::operator >>(std::basic_istream<char,_Traits> &,signed char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::basic_ostream<_Elem,_Traits>'
    1> with
    1> [
    1> _Elem=char,
    1> _Traits=std::char_traits<char>
    1> ]
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1060) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1060) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1060) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1060) : see declaration of 'std::operator >>'
    1>c:\users\jonbecher\documents\visual studio 2012\projects\bake\bake\bake.cpp(41): error C2784: 'std::basic_istream<char,_Traits> &std::operator >>(std::basic_istream<char,_Traits> &,signed char *)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::basic_ostream<_Elem,_Traits>'
    1> with
    1> [
    1> _Elem=char,
    1> _Traits=std::char_traits<char>
    1> ]
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1053) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1053) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1053) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1053) : see declaration of 'std::operator >>'
    1>c:\users\jonbecher\documents\visual studio 2012\projects\bake\bake\bake.cpp(41): error C2784: 'std::basic_istream<_Elem,_Traits> &std::operator >>(std::basic_istream<_Elem,_Traits> &,_Elem &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::basic_ostream<_Elem,_Traits>'
    1> with
    1> [
    1> _Elem=char,
    1> _Traits=std::char_traits<char>
    1> ]
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1028) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1028) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1028) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(1028) : see declaration of 'std::operator >>'
    1>c:\users\jonbecher\documents\visual studio 2012\projects\bake\bake\bake.cpp(41): error C2784: 'std::basic_istream<_Elem,_Traits> &std::operator >>(std::basic_istream<_Elem,_Traits> &,_Elem *)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::basic_ostream<_Elem,_Traits>'
    1> with
    1> [
    1> _Elem=char,
    1> _Traits=std::char_traits<char>
    1> ]
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(987) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(987) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(987) : see declaration of 'std::operator >>'
    1> c:\program files\microsoft visual studio 11.0\vc\include\istream(987) : see declaration of 'std::operator >>'
    1>c:\users\jonbecher\documents\visual studio 2012\projects\bake\bake\bake.cpp(41): error C2676: binary '>>' : 'std::basic_ostream<_Elem,_Traits>' does not define this operator or a conversion to a type acceptable to the predefined operator
    1> with
    1> [
    1> _Elem=char,
    1> _Traits=std::char_traits<char>
    1> ]
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

  2. #2
    Join Date
    Jun 2012
    Posts
    11

    Re: [RESOLVED] Multiple Compparisons in one block help.

    this was the mistake I made, found and fixed

    Code:
     	case '5':
    		cout << "Expensive but good taste you have!" >> endl;

Tags for this Thread

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