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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:09:34+00:00 2026-05-30T12:09:34+00:00

I have some questions about C++ from a C# developer. For a few days

  • 0

I have some questions about C++ from a C# developer.

For a few days I have been looking at some C++ code, and I have the following questions:

  1. When do use Foo::, Foo. and Foo-> ?
  2. When do I use a real constructor and when just String a; (sometimes I need to do something like String a("foo");)
  3. What is the difference between these signatures: int foo(int a) and int foo(int &a)?
  • 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-30T12:09:35+00:00Added an answer on May 30, 2026 at 12:09 pm

    :: is used either to explicitly specify a namespace (std::string, for example, for the string class in the namespace std), or for static members of a class.

    . is used much as in C#, to refer to a member of a class.

    -> is used with pointers. If p is a pointer to an object obj, then p->x has the same meaning as obj.x.

    when do i use a real constructor and when just String a; (sometimes i need to do something like String a(“foo”);)

    When you need to. String a is roughly equivalent to C#’s a = new String() (with the caveat that if String is a non-POD type, it may contain uninitialized members.)

    If you need a initialized to a specific value, you do that. (either with String a("foo"), or with String a = "foo")

    where is the difference between these signatures: int foo(int a) and int foo(int &a)?

    The & denotes a reference. It’s not quite a C# reference, but there are similarities. In C#, you have value types and reference types, and reference types are always passed by reference.

    In C++, there’s no such distinction. Every type can be passed by value or by reference. The type T& is a reference to T. In other words, given the following code:

    void foo(int& j);
    void bar(int j);
    
    int i = 42;
    
    foo(i);
    bar(i);
    

    foo will get a reference to i, which means it it can modify the value of i.
    bar will get a copy of i, which means that any modifications it makes will not be reflected in i.

    You often use const T& (a reference to const T) as a way to avoid the copy, while still preventing the callee from modifying the object.

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

Sidebar

Related Questions

I have some questions about partitioning and strategy, how and when to use it.
i have some questions about constructors in ColdFusion : must i use the name
I have a few quick questions about the iPhone software development. I did some
I have some questions about basic CSS that I was unable to understand or
I have some questions about customers about NF mode for DB2. Google had very
I have some questions about multi-threaded programming and multi-core usage. In particular I'm wondering
I have some questions about logging, more specifically about setting it up and making
I have some questions about Perl's map function. Specifically: How does %hash = map
I have some questions about using MySQLi queries, and related memory management. Suppose I
I have some questions about the default values in a function parameter list Is

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.