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

Thread: Error c2678

  1. #1
    Join Date
    Oct 2012
    Posts
    1

    Error c2678

    Ok, so I have researched and researched and have been through my code dozens of times, and I can not seem to figure out why I keep getting:

    error C2678: binary '>>' : no operator found which takes a left-hand operand of type 'std::istream'

    here's a snippet of my code:

    Code:
    #include "ItemType.h"
    
    void ItemType::addListing(ofstream& output) const
    {
    	output.open("prgmlisting.dat");
    
    	if(!output.is_open())
    		cout << "sorry cannot open file!" << endl;
    	else
    		{
    			cout << "please enter name of channel: ";
    			cin >> channel; //This is where I keep getting the error
    			output << channel << endl;
    		}
    }
    Also note that I have included #include <string> and #include <iostream> in ItemType.h

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,127

    Re: Error c2678

    You didn't show the definition of the variable causing the error, channel.

  3. #3
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Error c2678

    If channel is not a built-in type (bool, char, int, double, etc.) not a library class (such as std::string) that has overloaded the operator >>, then you need to explicitly overload operator>> to be able to use it like you did.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center