Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. properties

properties

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zildjohn01
    wrote on last edited by
    #1

    hello, i was wondering if there is an equivalent of the c# feature "properties" in c++. i.e., the client sees it as a variable, but methods are called to access it. You should understand from this c# sample: // test.cs namespace MyApp { public class TestClass { private int _item; TestClass(int tmp) { _item = tmp; } public int data { get {return _item;} set {_item = value;} // 'value' is implicitly the value // being assigned to the property } static void Main() { TestClass x = new TestClass(17); int res = TestClass.data; // res is now 17 TestClass.data = 42; res = TestClass.data; // res is now 42 } } } any equivalient in c++ ?

    C 1 Reply Last reply
    0
    • Z zildjohn01

      hello, i was wondering if there is an equivalent of the c# feature "properties" in c++. i.e., the client sees it as a variable, but methods are called to access it. You should understand from this c# sample: // test.cs namespace MyApp { public class TestClass { private int _item; TestClass(int tmp) { _item = tmp; } public int data { get {return _item;} set {_item = value;} // 'value' is implicitly the value // being assigned to the property } static void Main() { TestClass x = new TestClass(17); int res = TestClass.data; // res is now 17 TestClass.data = 42; res = TestClass.data; // res is now 42 } } } any equivalient in c++ ?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      No. Properties do not exist in C++. Christian Graus - Microsoft MVP - C++

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups