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 3949910
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:32:57+00:00 2026-05-20T01:32:57+00:00

I have a CarClass.h file that declares CarClass . I then #import this CarClass.h

  • 0

I have a CarClass.h file that declares CarClass.
I then #import this CarClass.h file into my CarClass.m file where I of course then go on to implement all my CarClass methods.
Finally, my CarAPP.m file (which contains the main) ALSO #imports CarClass.h – and everything works just fine.

Ss there are actually no problems there 🙂

However, I’m not sure I understand WHY it works – cause the linkage seems a little off: if CarAPP.m imports ONLY the CarClass.h file – without also importing the CarClass.m file, then where does it GET or SEE the implementations from?
Is it the case that once the “.m” file – which imports the “.h” file – is compiled, then the two files (.h and .m) are sorta forever linked or something?
I just don’t get it…

  • 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-20T01:32:58+00:00Added an answer on May 20, 2026 at 1:32 am

    The compiling process is split in different phases, and #import directives are interpreted long before any linkage occurs.

    When you give code files (.c, .m) to your compiler, it will try to generate a code object file (.o) from it; that is, a binary representation of your code. This file is not yet executable because it needs more information. Especially, it’s not linked to any other file. Header files, supposed to contain only declarations and no definition, typically don’t get their own matching .o file.

    After all your code files have been made into code objects, the compiler will put them all together and invoke the linker. The linker will resolve all external references, and then will produce an executable file.

    The point is that header files tell the compiler that a function or method exists somewhere. This is enough at the current phase of compilation to produce object files: the compiler just needs to be told what exists, not where’s the definition. Only when you actually link you need to know this.

    Since all your code object files get packaged together, your whole program gets access to everything that was publicly declared within itself. This is why you don’t need to explicitly “link” CarAPP.m against CarClass.m.

    It’s also possible to mislead the compiler and declare functions in header files that not defined anywhere. If you use them in your program, the first phases of compilation will go just fine (no syntax error, no “undeclared function”) but it will break at link-time, since the linker won’t be able to locate the nonexistent function.

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

Sidebar

Related Questions

I've been programming with detours lately and all that comes with it. I have
have written this little class, which generates a UUID every time an object of
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
I have a (COM Interop based) ActiveX contol that I am trying to use
I'm having something of a dilemma and would appreciate some input. I have this
I have a Car class that inherits a Vehicle class. Both the Car and
Let's say I have a Car class in a game that can be played
I have an Array of AutoMobiles This array may contain SubClass Objects Truck or
I have a car-class like this: public class car { public String Name {get;
This is a follow up question to this post I have two models: CarType.cs

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.