473,396 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Function templates and sorting words

143 100+
I have this assignment where I am to create 3, 100 position arrays, 1 integer, 1 float, and 1 of quotes. Then I am to use a generic type function template to sort the integers into ascending order, same with the floats, and sort the words into order.

I've got the ints and floats working fine but the words ain't going so well. I am getting an error message that reads " error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)

Here's the code for the words I am trying to sort:

Expand|Select|Wrap|Line Numbers
  1.         //string array declaration
  2.     filein.open("QUOTES.DAT");  //open string filein
  3.     string sArray[100];             //declare string array
  4.     int NumS =     89;        //variable for size of string array
  5.  
  6.     for(int k = 0; k < NumS; k++)    //load string array
  7.         filein>>sArray[k];    
  8.  
  9.     cout<<"\n\nThe original word values:\n";
  10.     display(sArray, NumS);
  11.     sort(sArray, NumS);
  12.     cout<<"\n\nThe sorted word values:\n";
  13.     display(sArray, NumS);
  14.     cout<<endl<<endl;
  15.     filein.close();
  16.     filein.clear();
Any ideas?

I can supply more code if need be.

Thanks
Apr 14 '07 #1
2 1952
weaknessforcats
9,208 Expert Mod 8TB
This error:

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

means the compiler could not find the string::operator>> function so:

filein>>sArray[k];

can't compile.

Probably you have not:

#include <string>

in your program.
Apr 14 '07 #2
teddarr
143 100+
yep that was it.

I'm kinda embarrassed by that one. I've been doing this long enough now, I should have remembered that.

My brain was telling me it was something more complex than that.

Thanks for the help.
Apr 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: D. Roshani | last post by:
Hello ! I wonder if any one can help me to create a cosomize sorting order (as Macro or added small program in c++ or c# which does this work) in a Access Database contaning one table only words...
0
by: Sparko | last post by:
My Xml is as follows; <root> <st id="1"> <rt id="1"> <cr id="1" ca_w="" ca_x="" ca_y="" ca_z="" other attribs> <ct some attribs> <te some attribs /> <te some attribs />
0
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update...
7
by: Federico G. Babelis | last post by:
Hi All: I have this line of code, but the syntax check in VB.NET 2003 and also in VB.NET 2005 Beta 2 shows as unknown: Dim local4 As Byte Fixed(local4 = AddressOf dest(offset)) ...
3
by: CoolPint | last post by:
Can anyone explain how I can make the following function accept an default arguement for the last parameter, which should be an optional functor? template <typename T, typename FUNCTOR> void...
1
by: Anton Pervukhin | last post by:
Hi everybody! While trying to implement a generic sorting function which takes a member function(on which base the actual sort happens) as a parameter, I have met the problem that I need to use...
8
by: D. Roshani | last post by:
Hello Do you have any idea how I can create a Macro in Access which can do costume alphabetic sorting of only one column with foreign words (ISO-8859-1), I would like to define how I want...
1
by: GP | last post by:
I have created a datagrid that is creating columns dynamically at runtime using the template columns.Edit ,add & delete works fine. The only problem I face is with sorting,I am setting the sorting...
8
by: simchajoy2000 | last post by:
I thought the only thing I had to do to disable column sorting in VB.NET was to set datagrid.AllowSorting = False. Unfortunately this has never worked for me. I discovered another set of code...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.