No match for operator>> issue

I am running this program in a unix terminal but when I try to compile it gives a huge list of issues however i believe the issue is the part saying no match for operator>>. I realize the program is missing a lot it isn't near complete I would like to be able to compile it before I go much further though. I have no idea what is causing this error any help is greatly appreciated.

#include <iostream>
#include <vector>  
#include <string>

using namespace std;

int main()
{
    int ui = 0 ;
    vector<string> in;
    string temp = "0";
    int vsize = 0;

    while(ui != 5)
    {
            cout << "1.     Read" << endl;
            cout << "2.     Print" << endl;
            cout << "3.     Sort" << endl;
            cout << "4.     Search" << endl;
            cout << "5.     Quit" << endl;
            std::cin >> ui >> std::endl;

            if(ui = 1)
            {
                    while(temp  != "q")
                    {
                            std::cout << "Enter the next element (Enter 'q' to stop):" << std::endl;
                            std::cin >> temp >>  std::endl;
                            in.pushback(temp);
                            vsize++;
                    }
            }

            if(ui = 2)
            {
                    std::cout << "Sequence: ";
                    for (int i = 0; i < vsize; i++)
                    {
                            cout << in[i];
                    }
                    std::cout << std::endl;
            }

            if(ui = 3)
            {
            }
    }
    return 0;

}

Upvotes: 0

Views: 85

Answers (2)

Serge Ballesta
Serge Ballesta

Reputation: 148890

I would like to be able to compile it before I go much further... Nice!

But you should read the error and warning messages, they often help to understand the problem and the way to fix it (following uses CLang output):

ess.cpp:21:31: error: reference to overloaded function could not be resolved;
  did you mean to call it?
        std::cin >> ui >> std::endl;

You are trying to extract something into std::endl which is non sense. Just write std::cin >> ui;

ess.cpp:23:19: warning: using the result of an assignment as a condition without
  parentheses [-Wparentheses]
        if(ui = 1)

ui = 1 is an assignment. The equality test should be if (ui == 1)

ess.cpp:29:32: error: no member named 'pushback' in
  'std::__1::vector<std::__1::basic_string<char,
  std::__1::char_traits<char>, std::__1::allocator<char> >,
  std::__1::allocator<std::__1::basic_string<char,
  std::__1::char_traits<char>, std::__1::allocator<char> > > >'; did you
  mean 'push_back'?
                        in.pushback(temp);

... and I assume too that you did mean in.push_back(temp);

I only took once example for each error, you should be able to fix duplicates :-)

Upvotes: 0

rockworm
rockworm

Reputation: 11

You know you are doing assignments in your if-statements? Equality is written == in C++. Also, why the vsize? A vector has its own method for getting the size, in.size() would give you that.

Upvotes: 1

Related Questions