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"
#endif

I believe it is supposed to follow the model below
#ifndef CLASSNAME
#define CLASSNAME
body of include
#endif

Comments

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

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

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

    :-)[/color]
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!

Categories

In this Discussion