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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:53:04+00:00 2026-05-12T12:53:04+00:00

The meaning of both eludes me.

  • 0

The meaning of both eludes me.

  • 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-12T12:53:05+00:00Added an answer on May 12, 2026 at 12:53 pm

    A declaration introduces an identifier and describes its type, be it a type, object, or function. A declaration is what the compiler needs to accept references to that identifier. These are declarations:

    extern int bar;
    extern int g(int, int);
    double f(int, double); // extern can be omitted for function declarations
    class foo; // no extern allowed for type declarations
    

    A definition actually instantiates/implements this identifier. It’s what the linker needs in order to link references to those entities. These are definitions corresponding to the above declarations:

    int bar;
    int g(int lhs, int rhs) {return lhs*rhs;}
    double f(int i, double d) {return i+d;}
    class foo {};
    

    A definition can be used in the place of a declaration.

    An identifier can be declared as often as you want. Thus, the following is legal in C and C++:

    double f(int, double);
    double f(int, double);
    extern double f(int, double); // the same as the two above
    extern double f(int, double);
    

    However, it must be defined exactly once. If you forget to define something that’s been declared and referenced somewhere, then the linker doesn’t know what to link references to and complains about a missing symbols. If you define something more than once, then the linker doesn’t know which of the definitions to link references to and complains about duplicated symbols.


    Since the debate what is a class declaration vs. a class definition in C++ keeps coming up (in answers and comments to other questions) , I’ll paste a quote from the C++ standard here.
    At 3.1/2, C++03 says:

    A declaration is a definition unless it […] is a class name declaration […].

    3.1/3 then gives a few examples. Amongst them:

    [Example: [...]
    struct S { int a; int b; }; // defines S, S::a, and S::b [...]
    struct S; // declares S
    —end example
    

    To sum it up: The C++ standard considers struct x; to be a declaration and struct x {}; a definition. (In other words, “forward declaration” a misnomer, since there are no other forms of class declarations in C++.)

    Thanks to litb (Johannes Schaub) who dug out the actual chapter and verse in one of his answers.

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

Sidebar

Related Questions

As title says, the meaning of both eludes me.
Nullable (C#) has a bit different meaning, but anyway both Option (Scala) and Nullable
Are both completely different concepts? Or is there an overlap in their meaning? Would
...meaning pattern in its general English usage, not specific to OO design patterns. Given
Meaning: A user auth's to an application -> application sets the namespace of the
What meaning has <E> on the code Collection<E> ?
Can't understand the meaning of this phrase. People on forums suggests each other to
What is meaning of Use Custom Permissions check-box in Magento installer? version 1.7.0.0
What is the meaning of the OVER clause in Oracle?
What is the meaning for $! in shell or shell scripting? I am trying

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.