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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:55:46+00:00 2026-06-07T11:55:46+00:00

I come from a world of c# were doing something like this is allowed.

  • 0

I come from a world of c# were doing something like this is allowed. When I try it in c++ I get no compiler errors but I am not convinced it is actually working.

So to more experienced people are you allowed to do something like this:

Entity->SetPosition(Vector2(200, 400));

As In Vector2 is a class and the parameter for set position requires a vector? Is this allowed or do I need to pre-initialize the variable like so:

Vector2 aVector(200, 400);
Entity->SetPosition(aVector);

Thanks
David

  • 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-07T11:55:48+00:00Added an answer on June 7, 2026 at 11:55 am
    Entity->SetPosition(Vector2(200, 400));
    

    is fine (and preferable) if you’ve defined SetPosition as one of the following:

    void SetPosition(Vector2 const & v); //Okay : const reference
    void SetPosition(Vector2  v);        //okay : value
    

    that is, SetPosition accepts the argument as const reference, Or simply as value.

    This wouldn’t work though:

    void SetPosition(Vector2 & v);  //not okay : non-const reference
    

    —

    In C++11, you could just write this (provided you have implemented Vector2 to enable this behavior):

    Entity->SetPosition({200, 400});
    

    Thanks to @Simon for pointing this out.

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

Sidebar

Related Questions

I come from the Java world, so to me it's all object.foo() , but
I come from the iPhone development world but have never developed desktop applications. Now
I may be hopelessly lost here, but having come from a MVC.NET world I
I'm a bit of a NuGet newbie and have come from the Maven world.
I come from the asp.net world where we'd use an objectdatasource, hooked up to
Possible Duplicate: Where does ‘Hello world’ come from? What was the first Hello World
This is an example XML file that would come from the Android Client. <test>
I come from a C and C++ background but also play with some web
I have two tables that I would like to get data and from by
For a data frame populated from a SQL query which looks like this: Company

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.