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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:18:07+00:00 2026-05-10T21:18:07+00:00

In C++, is the return type considered part of the function signature? and no

  • 0

In C++, is the return type considered part of the function signature? and no overloading is allowed with just return type modified.

  • 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. 2026-05-10T21:18:07+00:00Added an answer on May 10, 2026 at 9:18 pm

    Normal functions do not include the return type in their signature.

    (note: i’ve rewritten this answer, and the comments below don’t apply to this revision – see the edit-history for details).

    Introduction

    However, the matter about functions and function declarations in the Standard is complicated. There are two layers that have to be considered:

    • Declarations
    • Entities

    The so-called function declaration may declare a function entity or a template entity. If a function entity is declared, then you either have to do with an explicit specialization of a function template (with all arguments specified), or a declaration of an ordinary function. If a template entity is declared, then you are declaring a primary function template, or an explicit specialization where some arguments are not specified. (This is very similar to the relation of "object declaration" and objects or references: The former may declare either an object or a reference. So an object declaration may not necessarily declare an object!).

    The Standard defines the signature of a function to include the following at 1.3.10:

    The types of its parameters and, if the function is a class member, the cv- qualifiers (if any) on the function itself and the class in which the member function is declared. The signature of a function template specialization includes the types of its template arguments. (14.5.5.1)

    It’s missing the return type in this definition, which is part of the signature of a function template specialization (i.e a function declaration that declares a function which is a specialization of a template), as pointed out by 14.5.5.1 (recent C++0x working papers fixed that already to mention the return type in 1.3.10 too):

    The signature of a function template specialization consists of the signature of the function template and of the actual template arguments (whether explicitly specified or deduced).

    The signature of a function template consists of its function signature, its return type and its template parameter list.

    So what exactly does a signature contain, again?

    So, when we ask about the signature of a function, we have to give two answers:

    • For functions that are specializations of function templates, the signature includes the return type.
    • For functions that are not specializations, the return type is not part of the signature.

    Notice, however, that the return type, in any case, is a significant part of the type of a function. That is, the following is not valid:

    void f(); int (*pf)() = &f; // different types! 

    When is an overload invalid if only the return type differs?

    Major compilers currently reject the following code:

    int f(); double f(); // invalid 

    But accept the following code:

    template<typename T> int f(); template<typename T> double f(); // invalid? 

    However, the Standard does forbid a function declaration that only differs in the return type (when defining when an overload is valid, and when not). It does not define precisely what "differs only by return type" means, though.


    Standard paragraph references:

    • When can a function declaration be overloaded: 13.1
    • What is a function declaration: 7/2 and 7/5
    • What is the signature of a function template/specialization: 14.5.5.1

    For reference, here is what the most recent C++0x draft n3000 says about "signature" in 1.3.11, which is much more complete in its coverage of the different type of entities:

    the name and the parameter type list (8.3.5) of a function, as well as the class or namespace of which it is a member. If a function or function template is a class member its signature additionally includes the cv-qualifiers (if any) and the ref-qualifier (if any) on the function or function template itself. The signature of a function template additionally includes its return type and its template parameter list. The signature of a function template specialization includes the signature of the template of which it is a specialization and its template arguments (whether explicitly specified or deduced). [ Note: Signatures are used as a basis for name mangling and linking. — end note ]

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

Sidebar

Related Questions

Why return type of a method is not considered in method overloading ? Can
I have a Java code where the return type of a function has unbounded
Consider this code: public <T> List<T> meth(List<?> type) { System.out.println(type); // 1 return new
What return type should one return from a method that is getting rows from
Can I use yield return when the return type is an IGrouping<TKey, TElement> or
I have this as a return type in Scala Map[String, Seq[Map[String, Seq[MyClass]]]] I have
How can you describe the parameters and return type (getter/setter) of your PHP functions?
I know that there is no return type of the constructors in C++ However,
I have a thread with return type DWORD in C but it is then
how do I find out the return type of a method from the MethodBase?

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.