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 i've just recently been getting a hang of sockets but ran into
Hey guys, I just started learning C++ and I have this code that I
Hey guys, I'm doing an ASP.NET MVC project just for learning...and stuck in this...
Hey guys just a quick question about the performance of drawRect: as I've noticed
Hey guys this should be simple, I'm just not seeing it, I would like
Hey I'm just learning C in school and I have this idea for a
Hey guys I've just started programming and I'm running into a problem. The new
hey guys, how can I just achieve this simple layout? I'm hoping the answer
hey guys I'm just writing a name getter app as I'm learning android and
Hey guys this question is a bit nebulous so I apologize...I'm just looking for

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.