Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

While doing my C++ homework I ran into a compilation error when running my program. The error is directly below as are both the files

While doing my C++ homework I ran into a compilation error when running my program. The error is directly below as are both the files of my code. I do not understand what to do from here.

/tmp/cc9wZRNN.o:pw.cpp:(.text+0x335): undefined reference to `StudentProfile::setname(std::string)' /tmp/cc9wZRNN.o:pw.cpp:(.text+0x335): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `StudentProfile::setname(std::string)' /tmp/cc9wZRNN.o:pw.cpp:(.text+0x37f): undefined reference to `StudentProfile::setmajor(std::string)' /tmp/cc9wZRNN.o:pw.cpp:(.text+0x37f): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `StudentProfile::setmajor(std::string)' /tmp/cc9wZRNN.o:pw.cpp:(.text+0x3ca): undefined reference to `StudentProfile::setterm(std::string)' /tmp/cc9wZRNN.o:pw.cpp:(.text+0x3ca): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `StudentProfile::setterm(std::string)' collect2: error: ld returned 1 exit status

Student.h

#include

using namespace std;

class StudentProfile{

string name;

double marks[5];

string major;

string term;

public:

StudentProfile(){

}

void setname(string s);

string getname();

void setmajor(string m);

string getmajor();

void setterm(string t);

string getterm();

void setmarks(int val, int index){

marks[index] = val;

}

double findAverage();

void displayProfile();

};

Student.cpp

#include #include "Student.h" #include #include

//For getting name value string StudentProfile :: getname(){ return name; }

//For getting major value string StudentProfile :: getmajor(){ return major; }

//For getting term value string StudentProfile :: getterm(){ return term; }

//For calculating average of the marks double StudentProfile :: findAverage(){ return (marks[0] + marks[1] + marks[2] + marks[3] + marks[4]) / 5; }

//For display profile void StudentProfile :: displayProfile(){ cout << " Entered Student Information " << endl; cout << "Name: " << getname() << endl; cout << "Major: " << getmajor() << endl; cout << "Term: " << getterm() << endl; cout << "Term average: " << findAverage() << "%" << endl; };

//Main Program int main() { //Declared variables and object of //Student Profile StudentProfile studentProfile; string name; string major; string term; int mark; int index = 0; bool canProceed = true; //Get user input for student information printf("Enter Student Information "); printf("Name: "); cin >> name; studentProfile.setname(name); printf(" Major: "); cin >> major; studentProfile.setmajor(major); printf(" Term: "); cin >> term; studentProfile.setterm(term); printf(" Marks (Total of 5): ");

//Validate till the user enter valid mark //and if count of mark reaches 5 while(canProceed) { cout << " Mark " << (index + 1) << ": "; cin >> mark; if(mark <= 0 || mark > 100) { cout << "Mark should be between 0 and 100! Please Try Again." << endl; } else { studentProfile.setmarks(mark, index); index = index + 1; } if(index == 5) { canProceed = false; } } //Display the user input values //and calculate the average mark percentage studentProfile.displayProfile();

return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DNA Databases

Authors: Stefan Kiesbye

1st Edition

0737758910, 978-0737758917

More Books

Students also viewed these Databases questions

Question

What are the challenges associated with tunneling in urban areas?

Answered: 1 week ago

Question

What are the main differences between rigid and flexible pavements?

Answered: 1 week ago

Question

What is the purpose of a retaining wall, and how is it designed?

Answered: 1 week ago

Question

How do you determine the load-bearing capacity of a soil?

Answered: 1 week ago

Question

what is Edward Lemieux effect / Anomeric effect ?

Answered: 1 week ago