Machine-translated by Google. Questions are authored in English.
Top

Discussion

What is the use of "#pragma once"?

  • A.Used in a header file to avoid its inclusion more than once
  • B.Used to avoid multiple declarations of same variable
  • C.Used in a c file to include a header file at least once
  • D.Used to avoid assertions

Answer: A

Correct answer: Used in a header file to avoid its inclusion more than once

#pragma once tells the preprocessor to include the file at most once per translation unit, however many times it is named. It does the same job as the traditional include guard (#ifndef HDR_H / #define HDR_H / #endif) with less typing, at the cost of not being in the standard - though every mainstream compiler supports it.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.