Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6094789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:43:14+00:00 2026-05-23T12:43:14+00:00

I had ever used the following code snippet in one class. Today, I copied

  • 0

I had ever used the following code snippet in one class. Today, I copied it to another class. When compiling, I got the following errors. It is strange that such a thing has actually happened! Would you please tell what’s the matter? Thank you.

I’ve just been using the following snippet code to do a test in a demo project. I ran like a charm!

int main()
{  
   char buffer[] = "I1 I2 V1 V2 I3 V3 I4 DO V4";

   std::stringstream s(buffer); 
   std::istream_iterator<std::string> begin(s); 
   std::istream_iterator<std::string> end; 
   std::vector<std::string> IVector;
   std::vector<std::string> VVector;

   for ( ; begin != end; ++begin) 
   {     
       std::string sElem = *begin;

       switch((*begin)[0])
       {  
          case 'I':
            IVector.push_back( sElem);
            break;
          case 'V':
            VVector.push_back( sElem);
            break;
          default:
           ;
       }
   }

   return 0;
}

void ClassifyChannel(char* szBuffer)
{   
    // Empty vectors
    m_svIRChannels.clear();
    m_svVISChannels.clear();

    std::stringstream s(szBuffer); 
    std::istream_iterator<std::string> itBegin(s); 
    std::istream_iterator<std::string> itEnd; 

    for (; itBegin != itEnd; ++itBegin) 
    {     
        std::string sElem = *itBegin;

        // Switch on first character
        switch ((*itBegin)[0])
        {  
           // Infrared channel, such as IR1, IR2, IR3 (WV), and IR4
           case 'I':
           case 'W':
              // Insert into IR channel vector here 
              m_svIRChannels.push_back(sElem);
              break;
           // Visible channels, such as VIS, and VIS1KM
           case 'V':
              // Insert into VIS channel vector here 
              m_svVISChannels.push_back(sElem);
              break;
        }
    } 
} 

The error message is

error C2440: 'initializing' : cannot convert from 'std::string' to 'int'
1>        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>f:\tips\tips\fy2hdf5dataiohandler.cpp(830) : error C2664: 'std::istream_iterator<_Ty>::istream_iterator(std::basic_istream<_Elem,_Traits> &)' : cannot convert parameter 1 from 'int' to 'std::basic_istream<_Elem,_Traits> &'
1>        with
1>        [
1>            _Ty=std::string,
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        and
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]    
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:43:15+00:00Added an answer on May 23, 2026 at 12:43 pm

    What compiler are you using? Your code snippet compiles fine with VC10 on my box. Did you forget to include all the proper header files? For this piece of code you need these 3 headers:

    #include <string>
    #include <sstream>
    #include <iterator>
    

    Since VC10, <iterator> is not implicitly included by others. You need to include it yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Did you ever had a bug in your code, you could not resolve? I
Setup Have you ever had the experience of going into a piece of code
I was following a tutorial today that had me scratching my head for an
Anybody ever had the error Installation of the Microsoft Expression Web 2 product has
Have you ever had alternating background colors in a Jasper report and then exported
Have you ever had to justify the choice over using .NET instead of Java
Has someone here ever had experience with the D programming language ? It seems
Ever since deleting the original settings.settings file I have had endless problems getting the
I've never had the need to really ever use any of the .NET Data
Has anyone ever tried, or had any success at getting Wascana (Eclipse CDT +

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.