encyclopegia.org

Value type and reference type

In certain computer programming languages, data types are classified as either value types or reference types, where values referenced by reference type variables are always implicitly accessed via references stored in those variables, whereas value type variables directly contain the values themselves.[src]

In certain computer programming languages, data types are classified as either value types or reference types, where values referenced by reference type variables are always implicitly accessed via references stored in those variables, whereas value type variables directly contain the values themselves.[src] class Foo { public int a; } Foo a = new Foo(); Foo b = a; a.prop = 3; a = new Foo(); a.prop = 1; Foo is a reference type, where a is initially assigned a reference of a new object, and b is assigned to the same object reference, i.e.[src] bound to the same object as a , therefore, changes through a is also visible to b as well.[src] Afterwards, a is assigned a reference (rebound) to another new object, and now a and b refer to different objects.[src] At the end, a refers to the second object with its prop field having the value 1 , while b refers to the first object with its prop field having the value 3 .[src] However, such as C++, the term "reference type" is used to mean an alias, and it is not possible to rebind a variable of a reference type once it is created, as it is an alias to the original object.[src] class Foo { public: int a; }; Foo a; a.prop = 1; Foo& b = a; Foo c = a; a.prop = 3; In C++, all non-reference class types have value semantics.[src] In the above example, b is declared to be a reference (alias) of a , and for all purposes, a and b are the same thing.[src] It is impossible to rebind b to become something else.[src] After the above example is run, a and b are the same Foo object with prop being 3 , while c is a copy of the original a with prop being 1 .[src] In C#, apart from the distinction between value types and reference types, there is also a separate concept called reference variables.[src] A reference variable, once declared and bound, behaves as an alias of the original variable, but it can also be rebounded to another variable by using the reference assignment operator = ref .[src] The variable itself can be of any type, including value types and reference types, i.e.[src] by passing a variable of a reference type by reference (alias) to a function, the object where the reference-type variable points to can also be changed, in addition to the object itself (if it is mutable).[src]

15 sentences · 15 cited inline · 0 references stored

References

No reference rows published for this article.

Cite this article

MLA

"Value type and reference type." encyclopegia.org, 2026, https://encyclopegia.org/wiki/value-type-and-reference-type. Accessed 28 November 2026.

Chicago

"Value type and reference type." encyclopegia.org. Accessed November 28, 2026. https://encyclopegia.org/wiki/value-type-and-reference-type.

APA

encyclopegia.org. (2026). Value type and reference type. Retrieved November 28, 2026, from https://encyclopegia.org/wiki/value-type-and-reference-type

Accessed November 28, 2026 · CC BY-SA 4.0 · citation page · JSON

CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1342201858 · 0.5 · snapshot enwiki-001342201858

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools
  • Careers — open roles: frontier engineers and sales partners
  • Index — every corpus, paper and record
  • Estate guide — what a public data estate is
  • Founder — Lois-Kleinner Alpasan
  • Records — DOIs and external deposits
  • Documents — one-pagers, PDFs and QR codes
  • Brand kit — logos and share images
  • Papers — plain-language briefs with citations
  • Browser — search engine, PWA and bookmarklet
  • Anticloud — the operator and its projects

As seen in Business Insider · 336 outlets · evidence DOIs · plain-language papers

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.