how do you use fileguards (#ifndef)?!!

This is what I got trying to use fileguards and it doesn't work. LList is the name of the class. LList.h is name of my header file.

#ifndef LList
#define LList
#include "LList.h"

I believe it is supposed to follow the model below
body of include


  • [color=Blue]It is better to put these lines INSIDE the header file itself:[/color]
    // FILE: LLIST.H
    #ifndef LLIST_H
    #define LLIST_H

    ... contents of the header file goes here ...

    #endif // LLIST_H
    [color=Blue]Then you simply include the file anywhere without bothering to surround it with guards - they are already inside the house!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion