View Single Post
  #2 (permalink)  
Old November 18th, 2004, 01:20 PM
jkmyoung jkmyoung is offline
Authorized User
 
Join Date: Nov 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to jkmyoung
Default

The incomplete class declarations in the header usually declare the functions, but have no actual code in them. that way, the amount of code you can include less code when you need to reference the class. The compiler will link it for you later.

eg. Queue.h
Code:
class Queue{
public Queue();
public void Enqueue(Object obj);
public Object Dequeue();
public Object Peek();
private Vector myVector;
}
and then in Queue.cpp you'd have the actual code for the functions:
Code:
#include "Queue.h"
public void Queue::Enqueue(Object obj){
  myVector.Add(obj);
}
... other functions
I think generally you include files in the header only if you reference them in the header, eg. in this example you'd have to include Vector.h in the header

In the .cpp file, include the header file of the class, as well as the header of any other classes you used that your header doesn't know about.

I hope this makes sense.
Reply With Quote