CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2010
    Posts
    75

    no operator found

    hello
    i got error LN 150


    Error 1 error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)


    what does mean ?

    PHP Code:

    # include <iostream>
    using namespace std;

    struct car 
        
    int model;
        
    int platenum;
        
    string brand;
        
    float milage;
        
    double price;
    };

    template <class type>
    class 
    arraylisttype {
    private :
        
    type *list;
        
    int maxsize;
        
    int length;

    public:
        
    arraylisttype(int size);    // constructor
        
    bool isempty(); // is empty 
        
    bool isfull(); // is full
        
    void insert(type elem); // insert
        
    void insertat(int loc,type elem); //      insertAT
        
    void insertend(type elem); // insertEND
        
    void seqsearch(type elem);
        
    void remove(int loc); // remove
        
    void removeat(type elem); // RemoveAT
        
    void retriveat(int loc type &elem); // retriveAT
        
    void print(); // print
    };

    template <class type>
    bool arraylisttype<type>::isempty() {    // isempty 
        
    return ( length ==0) }

    template <class type>
    bool arraylisttype<type>::isfull(){   // isfull
        
    return ( length == maxsize ) }

    template <class type>
    void arraylisttype<type>::insert type elem) {      // insert
        
    if (isfull())
            
    cout << " list is full ";
        else {
            
    int i=seqsearch(elem);
            if ( 
    i!=0
                
    cout << " no duplicate ";
            else
                list[
    length++]=elem;
        }
    }

    template <class type>
    void arraylisttype<type>::insertat (int loc,type elem) { // insertAT
        
    if ( length ==maxsize
            
    cout << " full list ";
        else if ( 
    loc <|| loc length)
            
    cout << " invalid location ";
        else {
            for (
    int i=lengthi>loci--)
                list [
    i] = list [i-1];
            list [
    loc ] = elem;
            
    length ++;
        }
    }

    template <class type>
    void arraylisttype<type>::insertend type elem) {  // insertEND
        
    if (isfull())
            
    cout << " full list ";
        else 
            list[
    length++]=elem;
    }

    template <class type>
    void arraylisttype<type>::seqsearch type elem) {   // seqsearch
        
    for ( int i=0i<lengthi++)
            if ( list[
    i] == elem)
                return 
    i;
        return -
    1;
    }

    template <class type>
    void arraylisttype<type>::remove (int loc) {    // remove 
        
    if ( isempty()) 
            
    cout << " list is empty";
        else if ( 
    loc <|| loc >length )
            
    cout << " invalid location ";
        else {
            for ( 
    int i=loci<length-1i++)
                list[
    i] = list[i+1];
            
    length --;
        }
    }

    template <class type>
    void arraylisttype<type>::removeat type elem ) {   // removeAT
        
    int loc seqsearch(elem)
            if ( 
    loc!=-1)
                
    removeat(loc)
            else
            
    cout << " not found ";
    }

    template <class type>
    void arraylisttype<type>::retriveat(int loc,type &elem) { // retrive
        
    if ( length ==)
            
    cout << " list is empty";
        else if ( 
    loc <|| loc length)
            
    cout << " invalid location";
        else 
            
    elem = list[loc];
    }

    template <class type>
    void arraylisttype<type>::print () {    // print 
        
    for ( int i=0i<lengthi++)
            
    cout << list[i]<<" ";
    }

    template <class type>
    arraylisttype<type>::arraylisttype(int size){ 
        if ( 
    size 
            
    maxsize =100;
        else
            
    maxsize size;
        
    length 0;
        list = new 
    type[maxsize];
    }

    int main () {
        
        
    arraylisttype<intmodel(100);
        
    arraylisttype<intplatenum(100);
        
    arraylisttype<stringbrand(100);
        
    arraylisttype<floatmilage(100);
        
    arraylisttype<doubleprice(100);

        
    int x;
        
    car c1;

        
    cout << " Input your choice : ";

        while ( 
    x!=
            switch (
    x) { 

                case 
    0cout << " EXIT";
                case 
    cout << " insert new car info :";
                    
    cin>>c1.model>>c1.platenum>>c1.brand>>c1.milage>>c1.price;
        
        }


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

    Re: no operator found

    #include <string>

  3. #3
    Join Date
    Apr 1999
    Posts
    27,449

    Re: no operator found

    In addition to the lack of #include <string>, you shouldn't call your variable by the name "list", as there already is a std::list class in C++.

    Regards,

    Paul McKenzie

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