Classes embedded in Classes
My intro computer science class went over classes fairly quick, and the teacher never as much as mentioned classes within classes. Now I'm in the next level class and the second lab requires a class to use another private class as a linked list with only access to the head and tail. My question about this is, what's the notation I'm supposed to use? Class Counter220 is a header, and i'm sure that I wouldn't be able to create "local_node *p;" in the .cpp file for the header so what would the correct form be? Counter220* local_node::p = Null? And then access it through local_node::p->count?
Sorry to be such a bother, but I don't have access to the course compiler until monday so i'm just writing out the rough draft.
Sorry to be such a bother, but I don't have access to the course compiler until monday so i'm just writing out the rough draft.
#ifndef COUNTER220_H_
#define COUNTER220_H_
#include
#include
#include
using namespace std;
class Counter220{
protected:
Counter220();
public:
virtual ~Counter220();
int increment(char *item_name);
int decrement(char *item_name);
int count(char *item_name);
static Counter220* Instance();
private:
class local_node{
public:
local_node *next;
char *name;
int count;
};
local_node *head;
local_node *tail;
};
#endif /*COUNTER220_H_*/
