C++中有解包赋值吗
void student::set_message(int Grade, int number, string research_direction, string job) {
m_Grade, m_number, m_research_direction, m_job = Grade, number, research_direction, job;
}
比如以上写法是不可行的,有可替代的写法吗
C++中有解包赋值吗
void student::set_message(int Grade, int number, string research_direction, string job) {
m_Grade, m_number, m_research_direction, m_job = Grade, number, research_direction, job;
}
比如以上写法是不可行的,有可替代的写法吗
啥意思,你这函数要干啥呢?
必须逐个赋值,或者你将四个成员变量形成一个结构体,然后参数也用这个结构体,这样可以直接赋值
typedef struct _info
{
int grade;
int number;
string research_direction;
string job;
}info;
void student::set_message(info in) {
m_Info = in;
}