Link to home
Start Free TrialLog in
Avatar of mohrk
mohrkFlag for United States of America

asked on

C++ Homework Help Nested classes

Hi,

Alright 10 minutes into this thing and I am already stuck. I have a class Employee that seems fine, another class Student again fine.

Now I need a class TeachingAssistant nesting the first two classes. Sounds easy:
My header for just getting started:

#ifndef TEACHINGASSISTANT_H
#define TEACHINGASSISTANT_H

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

class TeachingAssitant
{
public:
	TeachingAssitant();
	class Employee;
	class Student;
};

#endif

Open in new window


When I go to implement TeachingAssistant it won't see it. I am including the above header file so I am not sure how to get further.

#include "stdafx.h"
#include "TeachingAssisstant.h"

using namespace std;

TeachingAssistant::TeachingAssistant() <- error

Open in new window


Thanks!
Avatar of TommySzalapski
TommySzalapski
Flag of United States of America image

Just a typo. You called the class TeachingAssitant in the .h file (missing an 's')

Also, your include for the .h looks like it has an extra 's'

Everything else looks like it should work.
Avatar of mohrk

ASKER

I think intellisense would have picked all of that up but I retyped it all to be sure.

"It" doesn't seem to like my constructor for TeachingAssistant. I just compiled and have a ton of errors. I will work through them and post an update. Should have tried that first. The errors are mostly in the other classess and implementations.

Sorry I got frustrated.

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of TommySzalapski
TommySzalapski
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mohrk

ASKER

Good tip thanks!