no match for operator>> !?

This is a discussion on no match for operator>> !? within the C++ Programming forums, part of the General Programming Boards category; Hi, I am a newbie programmer and is currently making a simple Dungeon Crawler, however I have encountered a problem. ...

  1. #1
    Registered User
    Join Date
    Feb 2012
    Location
    Malmö, Sweden, Sweden
    Posts
    2

    no match for operator>> !?

    Hi, I am a newbie programmer and is currently making a simple Dungeon Crawler, however I have encountered a problem. Here is my code:

    Code:
    #include <iostream>
    #include <cstdlib>
    
    const int LOW = 1;
    const int HIGH = 10;
    
    
    using namespace std;
    
    struct Entity
    {
        int Health;
        int Defence;
        int Attack;
    };
    
    int main()
    {
        Entity Goblin;
        Entity Character;
    
        Goblin.Health = rand() % (HIGH - LOW + 1) + LOW;
        Goblin.Defence = rand() % (HIGH - LOW + 1) + LOW;
        Goblin.Attack = rand() % (HIGH - LOW + 1) + LOW;
    
        Character.Health = 10;
        Character.Defence = 10;
        Character.Attack = 10;
    
        cout << "YOU ENCOUNTER A GOBLIN!" << endl << endl;
    
        cout << "Goblin's Health is " << Goblin.Health << endl;
        cout << "Goblin's Defence is " << Goblin.Defence << endl;
        cout << "Goblin's attack is "  << Goblin.Attack << endl << endl;
    
        cout << "Your Health is " << Character.Health << endl;
        cout << "Your Defence is " << Character.Defence << endl;
        cout << "Your Attack is " << Character.Attack << endl << endl;
    
    
        char attack;
        cin >> attack >> endl;
        cout << "You attack the Goblin" << endl;
    
        return 0;
    }
    The thing is, that this code giver me an error: no match for 'operator>>' in 'std:perator>> [with _CharT = char, _Traits = std::char_traits<char>](((std::basic_istream<char, std::char_traits<char> >&)(& std::cin)), ((char&)(& attack))) >> std::endl'|

    I have no idea what the problem is and would appreciate help

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    cin >> attack >> endl;
    You are trying to read something into endl. You can't. Only read into your attack variable.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Feb 2012
    Location
    Malmö, Sweden, Sweden
    Posts
    2
    Well.. that was embarrassingly easy.. but thank you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. no match for operator =
    By vaibhavs17 in forum C++ Programming
    Replies: 4
    Last Post: 03-30-2009, 01:38 PM
  2. no match for 'operator>>'
    By Taka in forum C++ Programming
    Replies: 3
    Last Post: 03-30-2009, 01:17 AM
  3. no match for 'operator=' in vector[][]
    By redmonkey in forum C++ Programming
    Replies: 5
    Last Post: 02-07-2009, 07:29 PM
  4. No Match For Operator+ ???????
    By Paul22000 in forum C++ Programming
    Replies: 24
    Last Post: 05-14-2008, 11:53 AM
  5. no match for operator << ??
    By neoragexxx in forum C++ Programming
    Replies: 6
    Last Post: 05-01-2006, 06:02 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21