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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:11:31+00:00 2026-06-10T09:11:31+00:00

I have two classes one called Person the other called Student I have been

  • 0

I have two classes one called “Person” the other called “Student” I have been chasing this around for a while and i just cannot get it to compile. I have had everything from Link error to what I have now.

 Person.h    
 #include <iostream>
 #include <string>

 using namespace std;

 class Person
 {
public:
    Person() 
    {
        cout << "Person: no parameters\n";
    }

    Person(string a, string b, string c, string d, string e, string f)
    {
        cout << "Person:" << a << endl;
        cout << "Person:" << b << endl;
        cout << "Person:" << c << endl;
        cout << "Person:" << d << endl;
        cout << "Person:" << e << endl;
        cout << "Person:" << f << endl;
    }

    ~Person();

    void Person::set_values (string a, string b, string c, string d, string e, string f)
    {
        name = a;
        address = b;
        city = c;
        state = d;
        zip = e;
        phone_number = f;
    }

protected:
    string phone_number;
    string name;
    string address;
    string city;
    string state;
    string zip;
 };

 Student.h
 #include <iostream>
 #include <string>


 #ifndef Person
 #define Person
 #endif

 using namespace std;

 class Student: Person
 {

 private:
string grade;
string course;
string gpa;

 public:
Student()
{
    cout << "Person: no parameters\n";
}

Student(string g, string h, string i)
{
    cout << "Person:" << g << endl;
    cout << "Person:" << h << endl;
    cout << "Person:" << i << endl;
}

~Student();

void setClass_values (string g, string h, string i)
{
    grade=g;
    course=h;
    gpa=i;
}
 };

 friendly2.cpp

 #include <iostream>
 #include <string>
 #include "Person.h"
 #include "Student.h"

 using namespace std;


 int main(void) 
 {
Person person;
Student student;
person.set_values("Fred", "825 Rice Street", "St. Paul", "MN","55421", "651-488-8888"); 
student.setClass_values("A", "Truck Driving", "4.0");

system("pause");
return 0; 
 }
 Error  12  error C2039: '{ctor}' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'   d:\visual studio 2010\projects\friendly\friendly\student.h  25  1   friendly
 Error  14  error C2039: '{ctor}' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'   d:\visual studio 2010\projects\friendly\friendly\student.h  25  1   friendly
 Error  16  error C2039: '{ctor}' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'   d:\visual studio 2010\projects\friendly\friendly\student.h  25  1   friendly
 Error  37  error C2039: '{ctor}' : is not a member of 'Student'    d:\visual studio 2010\projects\friendly\friendly\friendly2.cpp  15  1   friendly
 Error  3   error C2039: '{dtor}' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'   d:\visual studio 2010\projects\friendly\friendly\student.h  20  1   friendly
 Error  5   error C2039: '{dtor}' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'   d:\visual studio 2010\projects\friendly\friendly\student.h  20  1   friendly
 Error  7   error C2039: '{dtor}' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'   d:\visual studio 2010\projects\friendly\friendly\student.h  20  1   friendly
 Error  9   error C2039: '{dtor}' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'   d:\visual studio 2010\projects\friendly\friendly\student.h  25  1   friendly
 Error  10  error C2039: '{dtor}' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'   d:\visual studio 2010\projects\friendly\friendly\student.h  25  1   friendly
 Error  11  error C2039: '{dtor}' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'   d:\visual studio 2010\projects\friendly\friendly\student.h  25  1   friendly
 Error  13  error C2039: '{dtor}' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'   d:\visual studio 2010\projects\friendly\friendly\student.h  25  1   friendly
 Error  15  error C2039: '{dtor}' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'   d:\visual studio 2010\projects\friendly\friendly\student.h  25  1   friendly
 Error  17  error C2039: '{dtor}' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'   d:\visual studio 2010\projects\friendly\friendly\student.h  25  1   friendly
 Error  27  error C2039: '{dtor}' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'   d:\visual studio 2010\projects\friendly\friendly\student.h  35  1   friendly
 Error  28  error C2039: '{dtor}' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'   d:\visual studio 2010\projects\friendly\friendly\student.h  35  1   friendly
 Error  29  error C2039: '{dtor}' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'   d:\visual studio 2010\projects\friendly\friendly\student.h  35  1   friendly
 Error  38  error C2039: '{dtor}' : is not a member of 'Student'    d:\visual studio 2010\projects\friendly\friendly\friendly2.cpp  15  1   friendly
 Error  39  error C2039: '{dtor}' : is not a member of 'Student'    d:\visual studio 2010\projects\friendly\friendly\friendly2.cpp  15  1   friendly
 Error  42  error C2039: 'setClass_values' : is not a member of 'Student'   d:\visual studio 2010\projects\friendly\friendly\friendly2.cpp  17  1   friendly
 Error  1   error C2059: syntax error : '{' d:\visual studio 2010\projects\friendly\friendly\student.h  12  1   friendly
 Error  32  error C2065: 'course' : undeclared identifier   d:\visual studio 2010\projects\friendly\friendly\student.h  37  1   friendly
 Error  20  error C2065: 'endl' : undeclared identifier d:\visual studio 2010\projects\friendly\friendly\student.h  27  1   friendly
 Error  23  error C2065: 'endl' : undeclared identifier d:\visual studio 2010\projects\friendly\friendly\student.h  28  1   friendly
 Error  26  error C2065: 'endl' : undeclared identifier d:\visual studio 2010\projects\friendly\friendly\student.h  29  1   friendly
 Error  19  error C2065: 'g' : undeclared identifier    d:\visual studio 2010\projects\friendly\friendly\student.h  27  1   friendly
 Error  31  error C2065: 'g' : undeclared identifier    d:\visual studio 2010\projects\friendly\friendly\student.h  36  1   friendly
 Error  34  error C2065: 'gpa' : undeclared identifier  d:\visual studio 2010\projects\friendly\friendly\student.h  38  1   friendly
 Error  30  error C2065: 'grade' : undeclared identifier    d:\visual studio 2010\projects\friendly\friendly\student.h  36  1   friendly
 Error  22  error C2065: 'h' : undeclared identifier    d:\visual studio 2010\projects\friendly\friendly\student.h  28  1   friendly
 Error  33  error C2065: 'h' : undeclared identifier    d:\visual studio 2010\projects\friendly\friendly\student.h  37  1   friendly
 Error  25  error C2065: 'i' : undeclared identifier    d:\visual studio 2010\projects\friendly\friendly\student.h  29  1   friendly
 Error  35  error C2065: 'i' : undeclared identifier    d:\visual studio 2010\projects\friendly\friendly\student.h  38  1   friendly
 Error  36  error C2065: 'person' : undeclared identifier   d:\visual studio 2010\projects\friendly\friendly\friendly2.cpp  14  1   friendly
 Error  40  error C2065: 'person' : undeclared identifier   d:\visual studio 2010\projects\friendly\friendly\friendly2.cpp  16  1   friendly
 Error  41  error C2228: left of '.set_values' must have class/struct/union d:\visual studio 2010\projects\friendly\friendly\friendly2.cpp  16  1   friendly
 Error  8   error C2676: binary '<<' : 'std::ostream' does not define this operator or a conversion to a type acceptable to the predefined operator d:\visual studio 2010\projects\friendly\friendly\student.h  22  1   friendly
 Error  18  error C2676: binary '<<' : 'std::ostream' does not define this operator or a conversion to a type acceptable to the predefined operator d:\visual studio 2010\projects\friendly\friendly\student.h  27  1   friendly
 Error  21  error C2676: binary '<<' : 'std::ostream' does not define this operator or a conversion to a type acceptable to the predefined operator d:\visual studio 2010\projects\friendly\friendly\student.h  28  1   friendly
 Error  24  error C2676: binary '<<' : 'std::ostream' does not define this operator or a conversion to a type acceptable to the predefined operator d:\visual studio 2010\projects\friendly\friendly\student.h  29  1   friendly
 Error  43  error C3861: 'system': identifier not found d:\visual studio 2010\projects\friendly\friendly\friendly2.cpp  19  1   friendly
44  IntelliSense: expected a declaration    d:\visual studio 2010\projects\friendly\friendly\person.h   10  3   friendly
46  IntelliSense: expected an identifier    d:\visual studio 2010\projects\friendly\friendly\student.h  12  1   friendly
47  IntelliSense: identifier "person" is undefined  d:\visual studio 2010\projects\friendly\friendly\friendly2.cpp  11  9   friendly
45  IntelliSense: the global scope has no "set_values"  d:\visual studio 2010\projects\friendly\friendly\person.h   26  16  friendly

I Have tried with both classes in friendly2.cpp, but I just seem to keep chasing this around, Please 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-06-10T09:11:33+00:00Added an answer on June 10, 2026 at 9:11 am

    your code works with the following changes:

    person.h
    #pragma once
    
    #include <iostream>
     #include <string>
    
     using namespace std;
    
    class Person
    {
    public:
        Person() 
        {
            cout << "Person: no parameters\n";
        }
    
        Person(string a, string b, string c, string d, string e, string f)
        {
            cout << "Person:" << a << endl;
            cout << "Person:" << b << endl;
            cout << "Person:" << c << endl;
            cout << "Person:" << d << endl;
            cout << "Person:" << e << endl;
            cout << "Person:" << f << endl;
        }
    
        ~Person()
        {}
    
        void Person::set_values (string a, string b, string c, string d, string e, string f)
        {
            name = a;
            address = b;
            city = c;
            state = d;
            zip = e;
            phone_number = f;
        }
    
    protected:
        string phone_number;
        string name;
        string address;
        string city;
        string state;
        string zip;
     };
    
    student.h
    #pragma once
    
    #include <iostream>
    #include <string>
    #include "Person.h"
    
    using namespace std;
    
    class Student: Person
    {
    
     private:
    string grade;
    string course;
    string gpa;
    
     public:
    Student()
    {
        cout << "Person: no parameters\n";
    }
    
    Student(string g, string h, string i)
    {
        cout << "Person:" << g << endl;
        cout << "Person:" << h << endl;
        cout << "Person:" << i << endl;
    }
    
    ~Student()
    {}
    
    void setClass_values (string g, string h, string i)
    {
        grade=g;
        course=h;
        gpa=i;
    }
    };
    

    Your Problem was that you declared Destructors without defining them. If you insert a declaration the compiler won’t generate the automatically.
    I also added #pragma once to the headers. If you like traditional includeguards more, you should use the filename in capital letters (e.g. #ifndef PERSON_H … for Person.h). For larger projects I recommend to use include guards inEVERY header.

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

Sidebar

Related Questions

I have two classes one the Driver and the other one called FilterOut. In
I have two classes. One is called Employee and the other EmployeeDetails that has
I have two classes one of which inherits from the other. Im trying to
I have two classes, one that inherits from the other. The base class is
I have the following two classes, one inherits from the other Class A{ void
I have two classes called Person and Animal that have a lot of methods
Hi I have two classes, one called Instruction, one called LDI which inherits from
So I have two classes. One is a class called Main. The Main class
First, a little background (greatly simplified): I have two classes, one called Entity and
I have two classes, basically one holds Members and the other Sessions. They are

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.