In C#, there is a nice syntax sugar for fields with getter and setter. Moreover, I like the auto-implemented properties which allow me to write
public Foo foo { get; private set; }
In C++ I have to write
private: Foo foo; public: Foo getFoo() { return foo; }
Is there some such concept in the C++11 allowing me to have some syntax sugar on this?
Related Posts:
- Warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11?
- What is a lambda expression in C++11?
- ld: symbol(s) not found for architecture x86_64 error
- Expression must have class type
- What is the ‘override’ keyword in C++ used for? [duplicate]
- What is a smart pointer and when should I use one?
- Meaning of = delete after function declaration
- C++ std::priority_queue uses the lambda expression
- Usage and Syntax of std::function
- What exactly is nullptr?
- c++ “Incomplete type not allowed” error accessing class reference information (Circular dependency with forward declaration)
- Why is enum class preferred over plain enum?
- Difference between `constexpr` and `const`
- Split a string using C++11
- How to create timer events using C++ 11?
- Why am I getting this redefinition of class error?
- Single class has a Class Redefinition Error
- C++ Linked List Node with class
- (->) arrow operator and (.) dot operator , class pointer
- What does T&& (double ampersand) mean in C++11?
- Segmentation fault error 11 C++
- Why doesn’t C++ have a garbage collector?
- Compiling C++11 with g++
- terminate called after throwing an instance of ‘std::invalid_argument’ what(): stoi
- What exactly is std::atomic?
- Separating class code into a header and cpp file
- how to define -std=c++11 as default in g++
- Issue with std::stol – ‘std::invalid_argument’ what(): stol
- terminate called after throwing an instance of ‘std::out_of_range’
- Pointer to incomplete class type is not allowed
- Why am I getting this redefinition of class error?
- Cleanest way to copy a constant size array in c++11
- push_back vs emplace_back
- undefined reference to ‘std::cout’
- What is move semantics?
- expression preceding parentheses of apparent call must have (pointer-to-) function type
- C++ error: Undefined symbols for architecture x86_64
- no default constructor exists for class
- C++ terminate called without an active exception
- Thread pooling in C++11
- How does std::forward work? [duplicate]
- Getting error “a nonstatic member reference must be relative to a specific object” while both member are in the same class
- Error “C++ requires a type specifier for all declarations whilst defining methods”
- Difference in make_shared and normal shared_ptr in C++
- What are the differences between struct and class in C++?
- What is std::move(), and when should it be used?
- error C2011: ” : ‘class’ type redefinition
- C++: std does not have member “string”
- how to convert C# to C++
- push_back vs emplace_back
- error: use of deleted function
- The compiler is complaining about my default parameters?
- Call to implicitly deleted copy constructor in LLVM
- C++ Linked List Node with class
- Getting error: ISO C++ forbids declaration of with no type
- cc1plus: error: unrecognized command line option “-std=c++11” with g++
- “used without template parameters”
- expected constructor, destructor, or type conversion before ‘(’ token
- C++ Class ‘undeclared identifier”
- c++ “Incomplete type not allowed” error accessing class reference information (Circular dependency with forward declaration)
- error C2679: binary ‘<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
- Base class undefined
- no match for ‘operator<<’ in ‘std::operator
- What is the meaning of a C++ Wrapper Class?
- Use the auto keyword in C++ STL
- Call to non-static member function without an object argument compiler error
- G++ undefined reference to class::function
- Iterator Loop vs index loop
- Creating an instance of class
- initialize a vector to zeros C++/C++11
- When is it safe to call this-> in constructor and destructor
- How to memset char array with null terminating character?
- How well is Unicode supported in C++11?
- How to automatically convert strongly typed enum into int?
- Why should I use a pointer rather than the object itself?
- too many initializers for ‘int [0]’ c++
- overloaded function with no contextual type information
- Creating folders in C++
- expected primary-expression before ‘]’ token
- convert string to size_t
- Compiling C++11 with g++
- ERROR C2039: ‘vector’: is not a member of ‘std’
- error C2039: ‘string’ : is not a member of ‘std’, header file problem
- Does static constexpr variable inside a function make sense?
- istream and ostream problem – C++
- c++ vector bubble sort
- Struct with template variables in C++
- error: no member function declared in class
- Here is some error with my .h file which show [Error] unterminated #ifndef when I include my class template in it
- Error: invalid use of member in static member function
- How to use bitmask?
- Differences between unique_ptr and shared_ptr
- Is “delete this” allowed in C++?
- What is a segmentation fault?
- How many spaces for tab character(\t)?
- How to create a dynamic array of integers
- How to create a dynamic array of integers
- Linker Error C++ “undefined reference ” [duplicate]
- How do I build a graphical user interface in C++? [closed]
- C++ convert from 1 char to string?