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

  • SEARCH
  • Home
  • 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 8796893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:43:36+00:00 2026-06-13T23:43:36+00:00

I am new to C++, moving from Java and wondering about this: pos =

  • 0

I am new to C++, moving from Java and wondering about this:

        pos = result.find(remove[i]);  
        if (pos == string::npos)

is it calling the string “superclass”? I am confused if it is calling the class itself accesing the constant “npos” how does it know which instance of the class it is if I have several string variables declared in my function?

  • 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-06-13T23:43:37+00:00Added an answer on June 13, 2026 at 11:43 pm

    npos is not bound to an instance, but to the class itself. It’s a static member. There are static members in Java as well.

    21.4 Class template basic_string [basic.string]

    […]

    namespace std {
    template<class charT, class traits = char_traits<charT>,
    class Allocator = allocator<charT> >
    class basic_string {
      public:
        //...
        static const size_type npos = -1;
        //...
    };
    

    std::string is a specialization of basic_string.

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

Sidebar

Related Questions

I'm developer moving from C# to Java. Heard about new ASP net feature. <%:
I'm totally new to Flex (moving away from Java for now :(). I have
I'm moving my java project from Netbeans to Eclipse. I'm new to Eclipse and
I have noticed some developers picking up new skills and moving from one platform
I am attempting to automate moving files from a folder to a new folder
I'm moving my site from an oscommerce store to a commercial application. The new
I just create a new repo https://github.com/tolbard/ember-moving . In this repo I extend the
I have the opportunity for a new job in which I'd be moving from
I'm moving from Java to C++ right now and I'm having some difficulties whenever
I'm new to the rails environment and come from a java enterprise web application

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.