foo.cc:3:19: error: 'TreeNode' has not been declared
3 | void preorder(TreeNode *root, vector<int> &res) {
| ^~~~~~~~
foo.cc:3:35: error: 'vector' has not been declared
3 | void preorder(TreeNode *root, vector<int> &res) {
| ^~~~~~
foo.cc:3:41: error: expected ',' or '...' before '<' token
3 | void preorder(TreeNode *root, vector<int> &res) {
| ^
foo.cc:12:5: error: 'vector' does not name a type
12 | vector<int> preorderTraversal(TreeNode *root) {
| ^~~~~~
foo.cc: In member function 'void Solution::preorder(int*, int)':
foo.cc:7:9: error: 'res' was not declared in this scope
7 | res.push_back(root->val);
| ^~~
foo.cc:7:29: error: request for member 'val' in '* root', which is of non-class type 'int'
7 | res.push_back(root->val);
| ^~~
foo.cc:8:24: error: request for member 'left' in '* root', which is of non-class type 'int'
8 | preorder(root->left, res);
| ^~~~
foo.cc:9:24: error: request for member 'right' in '* root', which is of non-class type 'int'
9 | preorder(root->right, res);
| ^~~~~
[Hydro](https://hydro.ac)提供评测服务