+ Reply to Thread
Results 1 to 2 of 2

Thread: What is pragma once?

  1. #1
    Senior Member
    Join Date
    Feb 2012
    Posts
    109

    What is pragma once?

    What is pragma once?

  2. #2
    According to MSDN, it specifies that the file will be included (opened) only once by the compiler when compiling a source code file.

    Example:

    Code:
    //Your Header file.
    #pragma once
    
    class CStudent
    {
     ///anything you want...
    } ;
    Above file will be included only once when compiler compiles the a source file.

    This technique does not supported by all the compilers.

    Alternative example:

    Code:
    //Your Header file.
    #ifndef MY_HEADER_H
    #define MY_HEADER_H
    
    class CStudent
    {
     ///anything you want...
    } ;
    
    #endif //this should be last line in the header file

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts