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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:49:40+00:00 2026-06-16T01:49:40+00:00

The first if statement enters as suspected. The object calls the getCount() function but

  • 0

The first if statement enters as suspected. The object calls the getCount() function but the value that is incremented is not the previous count but instead 0. I tried using Count += Count in the function.

int main(){
    .........     
    int displayCount;
    while(!inputfile.eof()) 
    {

        inputfile.get(letter);

            Checker object1;
            if (object1.isValid(letter)))
            {
                displayCount = object1.getCount();
            }
    }
    cout << displayCount;
   .
   .
   .
Checker::Checker() :
    m_Valid(false),
    count(0)
{
}


int Checker::getCount()
{

    if(m_Valid)
    {
        count ++;
    }

    return count;
}

My inclination is that once the value is returned from the function then thats it. It will no longer hold the previous value bc of this (my guess).

  • 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-16T01:49:42+00:00Added an answer on June 16, 2026 at 1:49 am

    You just need to move Checker object1 outside of the loop; a new instance is being created with a count of zero for each pass as the code stands.

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

Sidebar

Related Questions

EDIT: My mistake was that I had a go after the first select statement
In the following code, the first log statement shows a decimal as expected, but
I have a case statement that returns a date; case when (ma.first_active_date is not
I have an sql statement that is supposed to return 2 rows. the first
I pretty much have this solved but for some reason the first If statement
This if statement is not working. I am trying to make it so that
First, I realize that from a performance perspective, the design of this switch statement
Using the lock statement , one can ensure that one thread does not enter
The first statement which uses this ( line 2 ) errors with: this is
#include<stdio.h> #include<signal.h> #include<stdlib.h> void handler(int signo) { printf(First statement); system(date); exit(EXIT_SUCCESS); } int main()

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.