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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:25:22+00:00 2026-05-18T12:25:22+00:00

I have two classes Person and Student. I’m currently trying to derive the Student

  • 0

I have two classes Person and Student. I’m currently trying to derive the Student class from the Person Class.

However, I keep getting a link error.

The error:

[Linker error] undefined reference to `Person::Person()' 

My code:

#include <iostream> 
#include <iomanip>
using namespace std; 

class Person { 

  string Name ;

public: 
  Person(void);

  void set(){ 

       cout << "Name:" << endl ;
       cin >> Name ; 
       } 

  string get_Name(){ 
      return Name ; 
      } 


};

class Student:Person { 
  int x, Lab1, Lab2, Lab3, Lab4, Lab5, Lab6, LabPoints, Midterm, Final ;
  float LabAvg, ExamAvg, Prcnt ; 
  string StuName ;

public: 
  Student(void);

  void set(int i){ 
       x = i; 

       cout << "Student " << x << endl << endl ;
       cout << "Name:" << endl ;
       cin >> StuName ;
       cout << "Lab 1 score (1-10): " << endl ;
       cin >> Lab1 ;
       cout << "Lab 2 score (1-10): " << endl ;
       cin >> Lab2 ;
       cout << "Lab 3 score (1-10): " << endl ;
       cin >> Lab3 ;
       cout << "Lab 4 score (1-10): " << endl ;
       cin >> Lab4 ;
       cout << "Lab 5 score (1-10): " << endl ;
       cin >> Lab5 ;
       cout << "Lab 6 score (1-10): " << endl ;
       cin >> Lab6 ;
       cout << "Midterm score (1-100): " << endl ;
       cin >> Midterm ;
       cout << "Final score (1-100): " << endl ;
       cin >> Final ;

       LabAvg = (Lab1 + Lab2) / 2.0 ;
       LabPoints = (Lab1 + Lab2) ; 
       ExamAvg = (Midterm + Final) / 2.0 ;
       Prcnt = (( ( LabPoints / 60.0 ) * 0.6 ) + ( ( Midterm / 100.0 ) * 0.2) + 
       ( ( Final / 100.0 ) * 0.2)) * 100 ;

       } 

  string get_StuName(){ 
      return StuName ; 
      } 

  int get_Lab1(){ 
      return Lab1 ; 
      } 

  int get_Lab2(){ 
      return Lab2 ; 
      } 

  int get_Lab3(){ 
      return Lab3 ; 
      } 

  int get_Lab4(){ 
      return Lab4 ; 
      } 

  int get_Lab5(){ 
      return Lab5 ; 
      } 

  int get_Lab6(){ 
      return Lab6 ; 
      } 

  float get_LabAvg(){ 
      return LabAvg ; 
      } 

  int get_LabPoints(){
      return LabPoints ; 
      } 

  float get_ExamAvg(){
      return ExamAvg ;
      } 

  float get_Prcnt(){
      return Prcnt ; 
      }
};

Student::Student(void){
  x = 0, Lab1 = 0, Lab2 = 0, Lab3 = 0, Lab4 = 0, Lab5 = 0, Lab6 = 0, 
  LabPoints = 0, Midterm = 0, Final = 0 ; 
  LabAvg = 0.0, ExamAvg = 0.0, Prcnt = 0.0 ; 
  StuName = "" ;
}

int main(){ 
  int MaxNumStu = 10, NumOfRep , i ; 
  float FPrcnt ; 
  string LetGrd ; 

  cout << "Number of Students:" << endl ;
  cin >> NumOfRep ; 
  cout << endl << endl ;

  Student obs[MaxNumStu] ; 

  NumOfRep = ++NumOfRep ;
  for(i=1 ; i < NumOfRep ; i++) 
    obs[i].set(i) ; 

  cout << endl << "---------------------------------" << endl << endl ; 

  for(i=1; i < NumOfRep; i++){
    cout << obs[i].get_StuName() << endl << endl; 
    cout << "Lab 1 Score: " << obs[i].get_Lab1() << endl ;
    cout << "Lab 2 Score: " << obs[i].get_Lab2() << endl ;
    cout << "Lab 3 Score: " << obs[i].get_Lab3() << endl ;
    cout << "Lab 4 Score: " << obs[i].get_Lab4() << endl ;
    cout << "Lab 5 Score: " << obs[i].get_Lab5() << endl ;
    cout << "Lab 6 Score: " << obs[i].get_Lab6() << endl ;
    cout << endl << "Average Lab Score: " << setprecision(4) << 
    obs[i].get_LabAvg() << endl ; 
    cout << "Total Lab Points: " << obs[i].get_LabPoints() << endl ;
    cout << endl << "Average Exam Score: " << setprecision(4) << 
    obs[i].get_ExamAvg() << endl ; 

    FPrcnt = obs[i].get_Prcnt() ;

    if ( FPrcnt >= 90 )
         LetGrd = "% A" ;
    if ( FPrcnt >= 80 )
         if ( FPrcnt < 90 )
            LetGrd = "% B" ;
    if ( FPrcnt >= 70 )
         if ( FPrcnt < 80 )
            LetGrd = "% C" ;
    if ( FPrcnt >= 60 )
         if ( FPrcnt < 70 )
            LetGrd = "% D" ;
    if ( FPrcnt < 60 )
         LetGrd = "% F";

    cout << endl << endl << "Overall Grade: " << setprecision(3) << FPrcnt 
    << LetGrd << endl;
    cout << endl << endl ; 
    }
  system( "pause" ) ;
}
  • 1 1 Answer
  • 1 View
  • 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-18T12:25:23+00:00Added an answer on May 18, 2026 at 12:25 pm

    You’ve declared a default constructor for Person:

    public: 
      Person(void);
    

    But never defined it.

    In this case, you don’t need to have your own default constructor – remove the declaration and let the compiler generate a default for you.
    Alternatively, you can define a do-nothing:

    Person::Person()
    {
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes, Person and Company, derived from another class Contact. They are
I have these two classes public class Person { } public class Company {
I have two classes (MVC view model) which inherits from one abstract base class.
I have two classes, one that inherits from the other. The base class is
I have these two classes: class Student { String name; String age ; }
I have two entity classes: Person and Position . public class Person { public
I have two classes: public class Person { public string FirstName { get {
I have this two classes: class Person(db.Model): person_name = db.StringProperty(required = True) #gender =
I have two classes (class A and B) both marked with [Binding]. Currently I'm
Let's say I have the following two classes: public class Person { public string

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.