Home » Community » Coffee corner » c++ standard read-only property flag would be handy 
	
		
		
			| c++ standard read-only property flag would be handy [message #49066] | 
			Tue, 12 December 2017 11:59   | 
		 
		
			
				
				
				
					
						  
						luoganda
						 Messages: 216 Registered: November 2016 
						
					 | 
					Experienced Member  | 
					 | 
		 
		 
	 | 
 
	
		for c/c++ language usually set/get are needed for properties, 
using public_read section or flag would be useful for 
properties, so there are not unneded code, eg: 
class Class{
  public:
  //accessed and modifiable by any
  int someProp;
  
  //this would be non-modifiable in outer usage
  public_read:
  int somePropX;
  //or
  int public_read somePropX;
  //or
  public_read int somePropX;
  //or something...
};
 
 
for compilers that would not implement this, 
just "unsafe" public: would be used instead.
		
		
		
 |  
	| 
		
	 | 
 
 
 |  
	
		
		
			| Re: c++ standard read-only property flag would be handy [message #49067 is a reply to message #49066] | 
			Wed, 13 December 2017 09:21    | 
		 
		
			
				
				
				  | 
					
						  
						mirek
						 Messages: 14271 Registered: November 2005 
						
					 | 
					Ultimate Member  | 
					 | 
		 
		 
	 | 
 
	
		luoganda wrote on Tue, 12 December 2017 11:59for c/c++ language usually set/get are needed for properties, 
using public_read section or flag would be useful for 
properties, so there are not unneded code, eg: 
class Class{
  public:
  //accessed and modifiable by any
  int someProp;
  
  //this would be non-modifiable in outer usage
  public_read:
  int somePropX;
  //or
  int public_read somePropX;
  //or
  public_read int somePropX;
  //or something...
};
 
 
for compilers that would not implement this, 
just "unsafe" public: would be used instead.  
 
IDK, people are having these various ideas about properties, but I do not understand why. Is it really so hard to write () ? 
 
Also, with (writable) properties, one can do things like 
 
a.ink = White;
a.font = Arial;
  
 
which IMO is really verbose and inconvenient compared to "U++ chained modifiers" style 
 
a.Ink(White()).SetFont(Arial());
  
		
		
		
 |  
	| 
		
	 | 
 
 
 |  
	
		
		
			| Re: c++ standard read-only property flag would be handy [message #49068 is a reply to message #49066] | 
			Wed, 13 December 2017 12:44    | 
		 
		
			
				
				
				
					
						  
						luoganda
						 Messages: 216 Registered: November 2016 
						
					 | 
					Experienced Member  | 
					 | 
		 
		 
	 | 
 
	
		Bar::Item(orIt'sDerivates) is a good example why. 
ToolButton is one such derivate. 
 
There is no way to read properties, only Set... are there like Text(), but no Get(), 
unless someone 1)subclasses it or 2)duplicate data in advance <=both is unneded 
 
If this c++ flags were available, there would be no hokus pokus to 
get those values now(noNeedToWrite Get...) and worying if both set/get is implemented, 
because they would already be available by design. 
 
+ you get direct access to it, no need to worry if 
setter/getter is written as by val/ref ,like ...& Get(...) and Set(...&) to access it byRef
		
		
		[Updated on: Wed, 13 December 2017 13:20] Report message to a moderator  
 |  
	| 
		
	 | 
 
 
 |  
	| 
		
 |  
	| 
		
 |  
	| 
		
 |  
	| 
		
 |   
Goto Forum:
 
 Current Time: Tue Nov 04 08:49:08 CET 2025 
 Total time taken to generate the page: 0.04937 seconds 
 |