Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
public class Record
{
 public string Record_Identifier { get; set; }
}


How to write the same thing in c++?
Posted

If you simply need to get and set a value without any validation simply use a public variable -
class Record
{
public:
    string Record_Identifier;
}

Now you will be able to use it like so -
Record rcd;
rcd.Record_Identifier = "Hello";
string var = rcd.Record_Identifier;
 
Share this answer
 
Comments
Member 10500446 11-Feb-14 1:55am    
You misunderstood the question. i askd that how to write the same property in c++?
«_Superman_» 11-Feb-14 2:02am    
I understand your question.
Native C++ does not support properties.
The way I put it is the closest you can get to the usage syntax of C# properties.
Otherwise, you simply use 2 functions with the name set and get (can be any name) as pointed out in the accepted answer.

My answer can also be interpreted as the question - Why do you need a property if you're not doing any validation on the value?
 
Share this answer
 
v2
Comments
Member 10500446 10-Feb-14 23:52pm    
thank you...
[no name] 10-Feb-14 23:54pm    
Glad to help..Accept the solution if it is helpful..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900