?
Solved

C++ Homework Help Nested classes

Posted on 2013-05-28
4
Medium Priority
?
298 Views
Last Modified: 2013-06-08
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!
0
Comment
Question by:mohrk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 39202237
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.
0
 

Author Comment

by:mohrk
ID: 39202586
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!
0
 
LVL 37

Accepted Solution

by:
TommySzalapski earned 2000 total points
ID: 39202645
If you're not already doing this, try compiling much more often. It will save you tons of time if you try compiling every time you write a class definition or function instead of waiting until you have dozens of new lines of code.
0
 

Author Closing Comment

by:mohrk
ID: 39232107
Good tip thanks!
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question