This question already has an answer here:
#include<iostream>
#include<string>
using namespace std;
class Student
{
protected:
string roll_number;
string name;
string course;
public:
void input_student()
{
cout << "Enter name of student: ";
cin.ignore(1, '\n');
getline(cin, name);
cout << "Enter roll number: ";
getline(cin, roll_number);
cout << "Enter course: ";
getline(cin, course);
}
void display_student()
{
cout << endl;
cout << "Name: " << name << endl;
cout << "Roll Number: " << roll_number << endl;
cout << "Course: " << course << endl;
}
};
class Class_exam :private Student
{
protected:
float mark1, mark2, mark3;
public:
void input_student();
void display_student();
void input_marks()
{
cout << endl;
cout << "Enter marks in Computer Programming: ";
cin >> mark1;
cout << "Enter Calculus: ";
cin >> mark2;
cout << "Enter marks in Data structure: ";
cin >> mark3;
}
void display_result()
{
cout << endl;
cout << "Marks in computer Programming: " << mark1 << endl;
cout << "Marks in calculus: " << mark2 << endl;
cout << "Marks in Data structure: " << mark3 << endl;
}
};
void main()
{
Class_exam exam[5];
for (int i = 0; i < 5; i++)
{
exam[i].input_student();
exam[i].input_marks();
}
for (int i = 0; i < 5; i++)
{
exam[i].display_student();
exam[i].display_result();
}
system("pause");
[in this image it shown my code error][1]}
i write this program, the second class is privately inherited. i call two functions in Class_exam class and call these functions in main function it gives me errors... anyone help me..
Error 1 error LNK2019: unresolved external symbol "public: void __thiscall Class_exam::input_student(void)" (?input_student@Class_exam@@QAEXXZ) referenced in function _main
Error 2 error LNK2019: unresolved external symbol "public: void __thiscall Class_exam::display_student(void)" (?display_student@Class_exam@@QAEXXZ) referenced in function _main
Error 3 error LNK1120: 2 unresolved externals
Aucun commentaire:
Enregistrer un commentaire