0
#include "Student.h"
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
Student::Student()
{
 name=" ";
 surname="";
 assignment1Mark=0;
 assignment2Mark=0;
 labTestMark=0;
 examMark=0;

}
Student::Student(string name,string surname,int a1, int a2, int test, int exam)
{
	name=name;
	surname=surname;
     assignment1Mark=a1;
     assignment2Mark=a2;
     labTestMark=test;
      examMark=exam;
}

string Student:: getName()const
{
	return name;
}

string Student:: getSurname()const
{
	return surname;
}

int Student:: getAssignment1Mark()const
{
	return  assignment1Mark;
}

int Student:: getAssignment2Mark()const
{
	return assignment2Mark;
}

int Student:: getLabTestMark()const
{
	return labTestMark;
}


int Student::getExamMark()const
{
	return examMark;
}

void Student:: setAssignment1Mark(int a1Mark)
{
assignment1Mark=a1Mark;
}

void Student::setAssignment2Mark(int a2Mark)
{
assignment2Mark=a2Mark;
}
void Student:: setLabTestMark(int lMark)
{
labTestMark=lMark;
}

void Student::setExamMark(int eMark)
{

examMark=eMark;
}

bool Student:: passed()const
{
if (((assignment1Mark + assignment2Mark) >= 20) && ((labTestMark + examMark ) >= 30))
return true;
else
return false;
}

string Student::getGrade()const
{
/*(NN 	-       if the Total Mark is less than 40;
MN 	-       if (40 <= Total Mark < 50) or (Total Mark >= 50 but student didn't pass);
P	-       if (50 <= Total Mark < 60) and student passed;
C 	-       if (60 <= Total Mark < 70) and student passed;
D	-       if (70 <= Total Mark < 80) and student passed;
HD 	-       if Total Mark >= 80;*/

	int totalMark=assignment1Mark+assignment2Mark+labTestMark+examMark;

	if(totalMark>=80)
	return "HD";
	else if((totalMark>=70 &&totalMark<80)&&passed())
		return "D";
	else if ((totalMark>=60 && totalMark<70) && passed())
		return "C";
	else if((totalMark>=50 && totalMark<60) && passed())
		return "P";
	else if(( totalMark>=40 && totalMark<50) || (totalMark>=50 && !passed()))
		return "MN";
	else
		return "NN";


}

ostream& operator<<(ostream& out, const Student & aStudent)
{
out<<endl;
out<<aStudent.getName<<" "<<aStudent.getSurname<<":"<<endl;
out<<"\t assignment1 maerk"<<aStudent.getAssignment1Mark<<endl;
out<<"\t assignment2 mark"<<aStudent.getAssignment2Mark<<endl;
out<<"\t lab test mark"<<aStudent.getLabTestMark<<endl;
out<<"\t exam mark"<<aStudent.getExamMark<<endl;
return out;
}

bool Student:: operator<(const Student &)const
{
	return true;

}

int main()
{
	Student b("bhuwan","rc",30,20,10,42);
	cout<<b;
	return 0;
}

when i compile this program
i got output like this
ompiling...
Student.cpp
H:\Assignment2c\Student.cpp(132) : error C2593: 'operator <<' is ambiguous
Error executing cl.exe.

Student.obj - 1 error(s), 0 warning
please anyone can tell me what is the problem with this

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by vmanes
0

Without line numbers present (please use code tags in the future), I'm guessing that this line is the offender

out<<aStudent.getName<<" "<<aStudent.getSurname<<":"<<endl;

You're asking the program to display the getName function, not the string that it returns. How does it work if you fix it like:

out<<aStudent.getName( )<<" "<<aStudent.getSurname( )<<":"<<endl;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.