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

  • Home
  • SEARCH
  • 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 747837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:15:05+00:00 2026-05-14T14:15:05+00:00

Same for CMap, CList, and pretty much everything that uses templates (I guess). I

  • 0

Same for CMap, CList, and pretty much everything that uses templates (I guess).

I find it a bit hard to understand when to use which. It’s true that for classes and such, the <class, class&> form is usually what you want, but for basic types like int, float, etc., which form is preferred?

  • 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-14T14:15:05+00:00Added an answer on May 14, 2026 at 2:15 pm

    I would say that if you don’t really need something else, just use CArray<Type> and ARG_TYPE would be its default const TYPE&. Actually using Type& as ARG_TYPE is not a good idea. This theoretically allows CArray to modify the object/value you passed to the corresponding method. Of course CArray doesn’t do anything like this but it is better to be on the safe side.

    If you look at the source code that is available within MS VC, you’ll see that ARG_TYPE is used in a few methods as type for argument that holds new value for some element(s) of the array such as

    void SetAt(INT_PTR nIndex, ARG_TYPE newElement)
    INT_PTR Add(ARG_TYPE newElement)
    void SetAt(INT_PTR nIndex, ARG_TYPE newElement)
    void InsertAt(INT_PTR nIndex, ARG_TYPE newElement, INT_PTR nCount = 1)
    

    If you making your choice between Type and const Type&, then the only thing that is affected is how many times and which data would be copied. When value is passed by reference, only pointer to it is actually passed. This is really important for objects (additional call of copy constructor) but doesn’t really matter for simple types. Of course you can try to save a few bytes by forcing copying char or short that is smaller than corresponding pointer (32/64 bit depending on platform) but I don’t think that this really worth additional troubles. As I said before, I think that using default CArray<Type> is a good way unless you really have reasons to change it.

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

Sidebar

Related Questions

find same node from two single linked lists. Can't use hash, Can not be
The same way i use this to detect when user scolled down the whole
I tote the same .vimrc between machines that have both Vim 7.2 and 7.3
I have the same problem that is listed in the following thread. WSDL first
Same problem was discussed earlier and I also knew that nothing, not also a
The same setup works on Windows 7 / 64 Bit and Windows Server 2008
Same for: $(#id option).show(); I'm just surprised. I thought that something went wrong with
Same as the title. I want to use sendBroadcast(intent) to start broadcast; and then
Same source, all that, just want a static and shared version both. Easy to
same as title, I'm pretty sure it has no difference, but just to be

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.