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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:50:46+00:00 2026-05-20T15:50:46+00:00

Hey guys, just learning about composition of classes and ran into this error. Gradebook.h

  • 0

Hey guys, just learning about composition of classes and ran into this error.

Gradebook.h

  #ifndef GRADEBOOK_h
#define GRADEBOOK_h

#include "StudentRec.h"
#include <iostream>
#include <string>

class GradeBook
{
public:
    GradeBook();

    GradeBook(string initLastName, int studGrades);

    void AddStudent(string initLastName, int studGrades);

    void ShowStudents();

    void UserInterface();

private:
    static const int numStudents=20;
    StudentRec student[numStudents];
    static int studentCounter;
    static int gradeCounter;
};

#endif 

Gradebook.cpp

     #include "Gradebook.h"
#include "StudentRec.h"
#include <iostream>
#include <string>

using namespace std;

GradeBook::GradeBook()
{}

GradeBook::GradeBook(string initLastName, int studGrades)
{}

void GradeBook::AddStudent(string initLastName, int studGrades)
{   
    gradeCounter++;   //Increments variable responsible for tracking # of grades per student
    StudentRec newStudent(initLastName, studGrades); //creates new student object
    student[studentCounter]=newStudent;  //Assigns new student object to array
    studentCounter++;  //Increments variable responsible for tracking # of students
}

void GradeBook::ShowStudents()
{
    for(int i=0;i<studentCounter; i++){  //Displays information for each student instance
        cout<<student[i].GetLastName()<<' ';
        for(int j=0; j<gradeCounter; j++)        
            cout<<student[i].GetGrades(j)<<' ';
        cout<<endl;
    }
}

void GradeBook::UserInterface()
{
    char choice=' ';
    string studLastName;
    int studGrade;

    cout<<"Welcome to GradeBook, this program stores students"
    <<" grades by last name.  To ADD a student press the 'A'"
    <<" key.  To LIST all students, press the 'L' key.  To "
    <<" QUIT, press the 'Q' key."<<endl<<endl;

    cin>>choice;

    choice=toupper(choice);

    while(choice!='Q')
    {
        if(choice='A'){
            cout<<"To add a student, please enter their last name"
            <<" followed by a space and a non-negative grade"
            <<" Ex. McClure 96";
            cin>>studLastName>>studGrade;

            AddStudent(studLastName, studGrade);
        }

        else if(choice='L'){
            cout<<"This is a list of all students in GradeBook"
            <<endl<<endl;

            ShowStudents(); //Displays all StudentRec objects
        }

        else if(choice!='Q')
            cout<<"Please enter another letter"<<endl;

        cout<<"To ADD a student press the 'A' key.  To LIST all students, press the 'L' key.  To "
        <<" QUIT, press the 'Q' key."<<endl<<endl;      
    }
}

Main.cpp

    #include <iostream>
    #include <string>
#include "StudentRec.h"
#include "Gradebook.h"

using namespace std;

int main()
{
    GradeBook gradeBook;

    UserInterface();

    return 0;

}

StudentRec.cpp

#include <iostream>
#include <string>
#include "StudentRec.h"

using namespace std;

StudentRec::StudentRec()
{
    lastName=" ";
    for(int i=0;i<numGrades; i++)
        grades[i]=0;
}

StudentRec::StudentRec(string initLastName, int studGrade)
{
    static int gradeCounter=0;
    lastName=initLastName;
    grades[gradeCounter]=studGrade;
}

string StudentRec::GetLastName()
{
    return lastName;
}

int StudentRec::GetGrades(int gradeNum)
{
    return grades[gradeNum];
}

void StudentRec::AddGrades(int studGrade)
{

    gradeCounter++;
    if(gradeCounter<=numGrades)
        grades[gradeCounter]=studGrade;
    else
        cout<<"Too many grades for this student";
}

StudentRec.h

#ifndef STUDENTREC_h
#define STUDENTREC_h

#include <iostream>
#include <string>

using namespace std;

class StudentRec
{
public:
    StudentRec();

    StudentRec(string initLastName, int studGrade);

    string GetLastName();

    int GetGrades(int gradeNum);

    void AddGrades(int studGrade);

private:
    static const int numGrades=10;
    static int gradeCounter;
    string lastName;
    int grades[numGrades];
};

#endif

In the Main.cpp file, I get an error I can’t find the solution for. It reads
error: “UserInterface” was not declared in this scope. I got this error while compiling in XCode
I got error C3861: ‘UserInterface’: identifier not found

Obviously i’ve tried it in two IDEs, I also have the StudentRec.cpp and .h, but not sure you need them. Thanks in advance for the help

  • 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-05-20T15:50:47+00:00Added an answer on May 20, 2026 at 3:50 pm

    It appears that UserInterface() is actually a member function of GradeBook, correct?

    If so, you need to add a declaration for the member function in the GradeBook class declaration:

    class GradeBook
    {
    public:
        GradeBook();
        GradeBook(string initLastName, int studGrades);
        void AddStudent(string initLastName, int studGrades);
        void ShowStudents();
    
        void UserInterface(); // Added
    
        // ...
    private:
        // ...
    };
    

    This way, the compiler will “know” that the UserInterface() function exists as a member function. You then provided the definition in void GradeBook::UserInterface() in your .cpp file.

    Then you need to call it on a GradeBook instance, like the gradeBook variable in your main() function:

    int main()
    {
        GradeBook gradeBook;
        // This calls the member function UserInterface() on the gradeBook variable.
        gradeBook.UserInterface();
        // This calls the global UserInterface(), which doesn't exist.
        // UserInterface();
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys just a quick question, I am posting mp3s in dialog boxes each
hey guys I just started trying to convert my query structure to PDO and
Hey guys - I just wrote an app using c# and ready to deploy
Hey guys I was just wondering how to make apps in two different languages?
Hey guys. Just wondering if anyone knows of a method to create sparkline graphs
Hey guys, just wondering if their is a simple way to create an Item
Hey guys, just installed on my Mac Snow Leopard OSX: Mono 2.6 and Monodevelop
hey guys, just having a bit of difficulty with a query, i'm trying to
hey guys, i'm getting an exception on the following inner exception: {Value cannot be
Hey guys i wrote a quick test. I want delete to call deleteMe which

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.