Hi there! I'm having a homework problem, but it's with the header code I was provided in the text. When I try to use it, I get "name lookup of 'x' changed for new ANSI 'for' scoping using obsolete binding at 'x'" Did I do something wrong? Or is there an easy fix? I've been looking for hours online for an answer and all I can seem to find is that other people have had similar problems - but no answer.
Please help me!
Thanks,
David In Toledo
#ifndef _ROLE
#define _ROLE
#include <iostream>
#include "student2.h"
#include "course2.h"
using namespace std;
const int maxstu=20;
class role {
public:
role( );
role(char * initCourseName, int initCourseId);
void addStudent(char * studentName, int studentId);
void setGrade(int studentId, char grade);
char * getStudent(int studentId);
char getGrade(int studentId);
void listRole( );
private:
course theClass;
int numStudents;
student courseRole[20];
char courseGrade[20];
};
role::role( ) {
theClass = course("-", -1);
numStudents = 0;
}
role::role(char * initCourseName, int initCourseId) {
theClass = course(initCourseName, initCourseId);
numStudents = 0;
}
void role::addStudent(char * studentName, int studentId) {
if (numStudents < maxstu)
{
courseRole[numStudents] = student(studentName, studentId);
courseGrade[numStudents] = '-';
numStudents++;
}
}
void role::setGrade(int studentId, char grade) {
for (int x=0; x < numStudents; x++)
if (courseRole[x].getId() == studentId) break;
if (x < numStudents)
courseGrade[x] = grade;
}
char * role::getStudent(int studentId) {
for (int x=0; x < numStudents; x++)
if (courseRole[x].getId() == studentId) break;
if (x < numStudents)
return courseRole[x].getName();
else
return "-";
}
char role::getGrade(int studentId) {
for (int x=0; x < numStudents; x++)
if (courseRole[x].getId() == studentId) break;
if (x < numStudents)
return courseGrade[x];
else
return '-';
}
void role::listRole( ) {
cout << endl << endl
<< "Class Name: " << theClass.getCourseName() << endl
<< "Class Id: " << theClass.getCourseId() << endl
<< endl << endl
<< "ID Name Grade" << endl
<< "==============================" << endl;
for (int x=0; x < numStudents; x++)
{
cout.width(3);
cout << courseRole[x].getId();
cout << " ";
cout << courseRole[x].getName();
cout.width( 20-strlen(courseRole[x].getName()) );
cout << ' ';
cout << courseGrade[x] << endl;
}
}
#endif