The below code should obviously not compile (Equivalent to defining a class as C { C myC }, which would take infinite memory). The question is how does C++ actually do the check?
class Node {
vector<Node> mChildren{ Node }
}
When I try to compile, I get the following error.
trie.cpp:6:35: error: expected primary-expression before ‘}’ token vector mChildren { Node }; ^ trie.cpp:6:35: error: could not convert ‘{}’ from ‘’ to ‘std::vector’
Is it because the class Node has yet to be fully declared? How come I can use it as a template argument to vector. A similar issue arises with
class C {
C myC;
};
Aucun commentaire:
Enregistrer un commentaire