|
-
March 20th, 2012, 12:22 PM
#1
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 <0 || loc > length)
cout << " invalid location ";
else {
for (int i=length; i>loc; i--)
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=0; i<length; i++)
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 <0 || loc >length )
cout << " invalid location ";
else {
for ( int i=loc; i<length-1; i++)
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 ==0 )
cout << " list is empty";
else if ( loc <0 || loc > length)
cout << " invalid location";
else
elem = list[loc];
}
template <class type>
void arraylisttype<type>::print () { // print
for ( int i=0; i<length; i++)
cout << list[i]<<" ";
}
template <class type>
arraylisttype<type>::arraylisttype(int size){
if ( size < 0 )
maxsize =100;
else
maxsize = size;
length = 0;
list = new type[maxsize];
}
int main () {
arraylisttype<int> model(100);
arraylisttype<int> platenum(100);
arraylisttype<string> brand(100);
arraylisttype<float> milage(100);
arraylisttype<double> price(100);
int x;
car c1;
cout << " Input your choice : ";
while ( x!=0 )
switch (x) {
case 0: cout << " EXIT";
case 1 : cout << " insert new car info :";
cin>>c1.model>>c1.platenum>>c1.brand>>c1.milage>>c1.price;
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|