The problem is same as I have titled. As you can see in blow code snippet, in main func line 21/22 works fine, I guess it try to invoke constructor but if the same thing I am doing in my class (line 16/17) it doesn't works.
For now I am considering I haven't default ctor explicitly.
#include <iostream>
#include <vector>
using namespace std;
struct HtmlElement {
HtmlElement(const string& name, const string& text) : m_name(name), m_text(text) {}
string m_name;
string m_text;
vector<HtmlElement> m_elems;
// more...
};
struct HtmlBuilder {
HtmlBuilder(const string& root_name) {}
// more...
HtmlElement m_root{"", ""}; // line 16
HtmlElement another_root("", ""); // line 17 (error)
};
int main() {
HtmlElement e("", ""); // line 21
HtmlElement another{"", ""}; // line 22
return 0;
}
I am not getting exactly what happening. Am I treating these braces (), {} wrongly in class/struct.