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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:32:54+00:00 2026-06-06T15:32:54+00:00

A short, maybe stupid question. For classes and structs, sometimes I like to have

  • 0

A short, maybe stupid question.
For classes and structs, sometimes I like to have member variables with the same name as constructor arguments. For example:

class Vector3
{
    float x, y, z;

    public Vector3(float x, float y, float z)
    {
        this.x = x;
        this.y = y;
        this.z = z;
    }
}

Basically, I want to do this for structs too, but you can’t use ‘this’ in struct constructors (their use is reserved for classes, I think). Is there a way to do this or should I just give my arguments another name?

  • 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-06T15:32:55+00:00Added an answer on June 6, 2026 at 3:32 pm

    You can use it, but its a pointer just as in classes:

    this->x = x;
    

    By the way, a struct and a class are exactly the same thing for everything but the default access specifiers.

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

Sidebar

Related Questions

maybe is stupid question but is there any way to write good looking (short
Short question you guys: I have a PHP string which may or maybe not
I have a short, and maybe simple question for some of you, but: How
This probably sounds like a stupid question, but I'm going to give it a
Maybe this is a stupid question, but I am wondering if I use dropbox
Just a short question: can Vectors be associative, like Array's? probably not, because I
I have a worker thread that may be active for short bursts of time
Maybe I'm overcomplicating things, but then again, I do sort of like clean interfaces.
Short best practice question: If an object A is injected into another object B,
Short version: I have a similar setup to StackOverflow. Users get Achievements. I have

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.