vs2013怎么快速生成类成员变量的get,set函数, 类似eclipse的功能
阿神2017-04-17 11:58:42
I remember that C# in vs uses ctr+r+e to quickly generate attributes for fields. As for c++, it seems that the syntax is not necessary.
ringa_lee2017-04-17 11:58:42
I have not found this function.
It is possible to use Qt Creator, move the cursor to the member variable, and then use the shortcut Alt + Enter and the option will appear.
If there are many member variables to be defined in VS, you can use the class wizard function to create a class.
If you don’t mind it, you can use the following macro definition
#ifndef MEM_GET_SET
#define MEM_GET_SET(member,member_type) \
member_type get_##member(){return member;}
void set_member(member_type value){ this->member = value;}
Use as follows
class A
{
public:
MEM_GET_SET(a,int)
private:
int a;
};