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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:25:15+00:00 2026-06-11T16:25:15+00:00

I am coming back to C++ after a long venture in Java world, and

  • 0

I am coming back to C++ after a long venture in Java world, and am regrasping the concept/syntax of how C++ uses pointers.

So a couple of examples.

in java

    public void MyFunc(MyClass class) 
    {
        class.DoSomething;
    }

is the same as

    void MyFunc (MyClass* class)
    {
        class->DoSomething;
    }

and

    public MyClass GetMyClass()
    {
        return class;
    }

is the same as (looking at it i realize i would have to store what im returning here in a pointer so its not the same…)

    MyClasss* GetMyClass()
    {
        return (&class); // could you say here "return <-MyClass"
    }

instead maybe this is the same (it would seem this should return an object of MyClass that is located at “&MyClass”, so you would be able directly edit this object at this location from wherever this is returning to )

    MyClasss GetMyClass()
    {
        return (&class);
    }

also you can use -> to access the object stored at the address the pointer points to, can you use <- to store the address?

finally, what is the point of

    void MyFunc(MyClass1 &class1, MyClass2 &class2)

vs

    void MyFunc(MyClass1* class1, MyClass* class2)

is it that for the first you are passing in the data store at the address while in example 2 you are passing in the address of the data you would like to use?

  • 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-11T16:25:16+00:00Added an answer on June 11, 2026 at 4:25 pm

    A pointer is a memory address where you can find your data (which can be an object, struct or primitive type). When you say return (&object), you’re returning a memory address – a single number (say, 1736cbfa). With that memory address, you can access individual elements of object using the -> operator. You’re not “pushing back” anything to the calling function, so you don’t need any “<-” operator. Just think of the function as returning a number, but a special kind of magic number that tells you where the data you need is, and you should be fine.

    Regarding your final point, void MyFunc(MyClass * object) sends a copy of the memory address/pointer/magic number where you find the data into the function. void MyFunc(MyClass & object) basically does the same thing behind the scenes, but allows you to refer to object1 directly (as in object.element instead of object->element). This second method is preferred when you want to modify object1 inside the function since you can’t accidentally dereference a null pointer this way.

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

Sidebar

Related Questions

I'm coming back to c++ after using Java for a long time. In Java
I'm coming back to C++ after long years spent on other technologies and i'm
I am coming back to facebook app development after a long time. And I
I am coming back to Android after a really long absence and it turns
I'm seeing some weird stuff happening in my app. After coming back to the
After much searching and googling I am coming back to the well. I have
First off, I'm coming (back) to Java from C#, so apologies if my terminology
I'm having a lot of trouble with Ruby after coming back to it from
I am coming back from after reading this c-faq question I am totaly confused
I'm coming back to programming after years off and am having trouble wrapping my

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.