在C++中,结构体的变量可以直接赋值,声明后可以直接使用。
#include <iostream>
using namespace std;
struct test {
int a = 10;
};
int main() {
test ttt;
cout << ttt.a << endl;
ttt.a = 100;
cout << ttt.a << endl;
}
在C++中,结构体的变量可以直接赋值,声明后可以直接使用。
#include <iostream>
using namespace std;
struct test {
int a = 10;
};
int main() {
test ttt;
cout << ttt.a << endl;
ttt.a = 100;
cout << ttt.a << endl;
}