结构体就算不用构造函数也可以初始化

标题结构体就算不用构造函数也可以初始化

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<set>
using namespace std;
struct stateAndLevel{
	string str;
	int level;
};

queue<stateAndLevel> q;
set<string> sc;
int n;


int main(){
	string src;
	string target;
	getline(cin,src);
	getline(cin,target);
	n=src.length();
	stateAndLevel first={src,0};				//通过这种方式即可初始化结构体
	return 0;
}

发布了99 篇原创文章 · 获赞 13 · 访问量 2694

猜你喜欢

转载自blog.csdn.net/qq_44378358/article/details/103516591