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 8718609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:35:35+00:00 2026-06-13T06:35:35+00:00

Today I start to learn c++ a bit and I begins to understand with

  • 0

Today I start to learn c++ a bit and I begins to understand with simple code, but this make confuse me

#include <iostream>

using namespace std;

class MyVar
{

    public:
        MyVar(){
            cout << "this is constructor" << endl;
        }
        void accesscheckpass(string x){
            checkpass(x);
        }

    private:
        bool checkpass(string x){
            if(x == "password"){
                return true;
            }
        }
};

int main()
{
    int inputpass;
    cout << "please enter your password\n" << endl;
    cin >> inputpass;

    MyVar MyAccess;

    if(MyAccess.accesscheckpass(inputpass) == true){
        cout << "welcome user 1" << endl;
    }else{
        cout << "get lost !" << endl;
    }

}

I want to validate the user when he/she entered the password, then when to section IF, when I want to compile it, compiler return the status “invalid conversion from ‘int’ to ‘const char*’ [-fpermissive]|”, please someone repair my code and explain what i’m wrong ?

  • 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-13T06:35:36+00:00Added an answer on June 13, 2026 at 6:35 am

    please someone repair my code

    Try to repair it yourself after we explain what’s wrong. You’ll gain much more from it than by us posting your code.

    explain what i’m wrong

    Sure. The method accesscheckpass expects a std::string as parameter (btw you need to #include <string> at the top of the file). You call it as

    MyAccess.accesscheckpass(inputpass)
    

    but inputpass is declared as int inputpass;, so it’s and int, not a std::string. So you either have to declare inputpass as a string or find out how to convert an int to a string. (should be easy)

    Also, your method:

        bool checkpass(string x){
            if(x == "password"){
                return true;
            }
        }
    

    only returns if the condition is true. You should have an else branch as well:

        else
            return false;
    

    or, better yet, return the result directly.

        bool checkpass(string x){
            return x == "password";
        }
    

    and your method

        bool accesscheckpass(string x){
           return  checkpass(x);
        }
    

    should return a bool as well.

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

Sidebar

Related Questions

I was working today and decided to start using JQUERY to make a toggle
My code was working fine yesterday, but I start it up again today and
I start dicoverig C# today ... as you know there is some difuculties using
I've been using using F5 (Start Debugging) for years to build the code (if
Today start using the new version of Netbeans 7.1.2, I get the below notice
Dear all. Today, I start to learn iOS. I don't know what tool I
Just today my STS instance is failing to start tcserver. We are using tc
I've been writing code for ASP.NET since the start, and today I encountered something
I've been using Think Python to learn programming over the last few days. Today
Yesterday everything works fine, but today I got many errors when I start my

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.