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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:15:40+00:00 2026-06-17T11:15:40+00:00

hi i would like to know what is the difference between doing template <typename

  • 0

hi i would like to know what is the difference between doing

template <typename T> class List :
   T& getData();        
AND
   T getData();
};     
  • 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-06-17T11:15:41+00:00Added an answer on June 17, 2026 at 11:15 am

    Given that T is a type, T& is a reference to an object of type T.

    T getData(); is a function which returns an object of type T. This means that, whatever the function returns will be copied and the caller will receive this copy. This is called “return by copy”. In practice, it is not always necessary to produce a copy, and a compiler can optimize it away (which is called “copy elision”).

    T& getData(); is a function which returns a reference to an object of type T. This is, quite understandably, called “return by reference” and means that the object returned is not copied. Instead, you simply return a reference to its location in memory, through which the original object can be accessed. When using this, care has to be taken that the returned reference isn’t used beyond the lifetime of the object to which it refers.

    If you do not know exactly what a reference is, it is essentially an alias which is used to refer to some variable. It’s often used as a safer alternative to a pointer, though unlike a pointer it is itself not an object, and you can never refer to the reference itself, and hence cannot change what it refers to.

    If you want to know more, the Wikipedia page is surprisingly helpful.

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

Sidebar

Related Questions

I would like to know what is the exact difference between a class snippet
I would like to know what the difference between these instructions is: MOV AX,
I would like to know what is the difference between Sleep mode and Deep
I would like to know is there any difference in performance between these two
I would like to know if there is a difference in speed between computing
I would like to know the difference and additional features in Antennahouse over Apache
I would like to know how to compare 2 different strings through a function
I have 2 object. In different depths of MovieClip. I would like to know
i would like know some reference. I know i can googling it. but prefer
Would like to know what a programmer should know to become a good at

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.