Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 789441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:31:34+00:00 2026-05-14T21:31:34+00:00

This is quite probably a very silly question but I need to be sure.

  • 0

This is quite probably a very silly question but I need to be sure. I’ve been given a class declaration in a header file eg.

#ifndef file_H
#define file_H

class ex{
private:

public:
};

#endif

and I’ve been required to write the method definitions in the same file, which I have done, my question is does the “#endif” stay where it is just after the class declaration or does it go at the end of my file after the class method definitions?.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T21:31:34+00:00Added an answer on May 14, 2026 at 9:31 pm

    At the end of the file.

    The goal of this form of this #ifndef pattern is to prevent a situation where the same declaration or definition appears twice in a compilation unit.

    This is done because a C file may include several H files, which somewhere up the chain may in turn include the same file. IF you simply ran the preprocessor without these, you would have multiple copies of the H file. This way, you have multiple copies, but the preprocessor ignores everything after the first encounter.

    Since you’re not supposed to be defining anything more than once, if you have to place method definitions in the header file, put them within the #endif.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably quite a simple question but very hard to google! I'm loading
This is probably a very obvious question but I can't quite figure it out.
This is probably a really simple question but one I've never quite worked out
This is probably very simple, but I'm quite new to ruby and active record.
This is a very basic question, but I'd quite like an explanation of why
This is, quite probably, a very rookie question as I'm just getting started with
Probably a silly question, but I'm new to all this. I am creating a
This is probably quite simple, but I just don't know how to do this...
This will be probable quite odd question. But i thought I will give it
This question is probably quite different from what you are used to reading here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.