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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:12:01+00:00 2026-06-13T16:12:01+00:00

I keep getting an error: unexpected end-of-file found and i am completely lost. I

  • 0

I keep getting an error: unexpected end-of-file found and i am completely lost. I have checked the curry braces and the parentheses I have put a semicolon at the end of the class I cant figure out whats wrong with it. thanks alot.

#include<iostream>
#include<fstream>
#include<string>
using namespace std;



class operations{
    void checkout(){
        cout << "Check out here!!";
    }
}
void main(){
    string item;
    int choice;

    cout << "What do you want to do? " << endl;
    cout << "Press 1 for checking out " << endl;
    cout << "Press 2 for stocking " << endl;
    cout << "Press 3 looking at recipts " << endl;
    cin >> choice;
    cout << choice;

    if(choice == 1){
        void checkout();
    }
    /*ofstream myfile;
    myfile.open("inventory.txt");

    if(myfile.is_open()){
        cout << "Enter a grocery item" << endl;
        getline(cin,item);
        myfile << item;
    }
    cout << "Your grocery item is " << item;
    myfile.close();
    system("pause");*/
};
  • 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-13T16:12:02+00:00Added an answer on June 13, 2026 at 4:12 pm

    This is your code, corrected as I interpreted what you wanted to perform.

    #include<iostream>
    #include<fstream>
    #include<string>
    
    using namespace std;
    
    class operations
    {
        public:void checkout()
        {
            cout << "Check out here!!";
        }
    };
    
    int main()
    {
        string item;
        int choice;
        operations op;
    
        cout << "What do you want to do? " << endl;
        cout << "Press 1 for checking out " << endl;
        cout << "Press 2 for stocking " << endl;
        cout << "Press 3 looking at recipts " << endl;
        cin >> choice;
        cout << choice;
    
        if(choice == 1)
        {
            op.checkout();
        }
    
        return 0;
    }
    

    First, note that semicolons are needed after class declarations, and not needed after method declarations

    Second, note that void checkout() in your code would not call the method that you defined in your class, but will instead declare a new method that will simply perform nothing. To call the right void checkout() you have to instatiate an object of type operations and then call its method with op.checkout()

    Last, always declare int main() and place return 0 if the executions flow arrives to the end of your program correctly.

    As a side note, I would probably not use a class in your program, but simply implement the methods correspondent to the user’s choice before the main() implementation

    void checkout()
    {
        cout << "Check out here!!";
    }
    

    so that you can call them simply with

    checkout()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting a syntax error (unexpected end of file). The syntax looks good
Hey guys! I keep getting a syntax error (unexpected $end), and I've isolated it
I keep getting the following error: Parse error: syntax error, unexpected T_SL in /home/a4999406/public_html/willingLog.html
I keep getting this error and have no idea why. I googled and scanned
I keep getting a syntax error Parse error: syntax error, unexpected '{' in contact_form.php
I have a rails application and i keep getting this error /srv/projects/app/controllers/application_controller.rb:174: invalid multibyte
I keep getting this error: SyntaxError: Unexpected token o For a v.simple piece of
I keep getting the error Parse error: syntax error, unexpected T_STRING on line #9
I keep getting this exception: Oops: CannotCompileException An unexpected error occured caused by exception
I keep getting an unexpected character error in the console for the line var

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.