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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:37:06+00:00 2026-06-15T19:37:06+00:00

I am currently working with classes and constructors. I have sint variable named current

  • 0

I am currently working with classes and constructors. I have sint variable named current that equals 0 inside the constructor. Now when I click the button I am trying to increment property current and then call GetNextTree to display. But when incrementing current++ from button click I receive this error: does not exist in current context. What would be the proper way to increment current then?

public class fruit_trees
    {

    } 
public class ListForTrees
        {
    public int current;

    public fruit_trees GetNextTree()
            {
                current = 0;
                fruit_trees ft = first_tree;
                int i = 0;
                while (i != current)
                {
                    ft = ft.next_tree;
                    i++;

                }

                return ft;

            }


    }

private void ShowNextItem_Click(object sender, EventArgs e)
        {
            //Show Last Item

            fruit_trees obj = mainlist.GetNextTree();


            if (obj == null)
            {
                labelSpecificTree.Text = "No more trees!";
            }
            else
            {
               //error: current does not exist?
        current++
                labelSpecificTree.Text = obj.next_tree.GetTreeType.ToString();

            }   

        }
  • 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-15T19:37:08+00:00Added an answer on June 15, 2026 at 7:37 pm

    The problem is in the scope (encapsulation) where you try to call int current.

    From your posted code, int current is defined in class ListForTrees. However you are trying to access it without initializing your object of type ListForTrees.

    In addition, you are using mainlist which is also not defined in your posted code. Please, post complete code coverage of items that you use in code.

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

Sidebar

Related Questions

I am currently working in Qt and so C++. I am having classes that
I am working with abstract classes and virtual methods. Currently I have a window
I'm currently working on an app that will tell students when their classes start
I'm currently working with Grails 1.3.7, and I have the following domain classes connected
I'm currently working on a libproject (Android) that should be included inside a few
Currently working with converting SQLException error messages into messages that are more useful for
Im currently working on a game that uses multi touch to apply zoom to
Am currently working on an application that requires users to submit posts and comments
I'm working on a little web-project-management-application. I have a few classes like Clients(), Services(),
I'm working on WinForms application. I have group of tests classes, each class performs

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.