header 的代码如下
#ifndef binary_tree_hpp
#define binary_tree_hpp
#include <iostream>
#include <string>
#include <stack>
#include <vector>
using namespace std;
struct Node{
Node * left;
Node * right;
int degree;
int key;
int value;
};
Node * root;
Node* add(Node *);
Node* add(int, int);
extern string print_tree(stack<Node*, vector<Node*>> = stack<Node*, vector<Node*>>(*new vector<Node*>(1,root)));
#endif /* binary_tree_hpp */
出问题的在 external 这一行,在 cpp 文件中是这样的
string print_tree(stack<Node*, vector<Node*>> nodes = stack<Node*, vector<Node*>>(*new vector<Node*>(1,root))){
cout<<nodes.top()<<endl<<root<<endl;
return "";
}
编译的时候就提示 redefinition of default argument 。
不知应该如何解决,在 google 上搜索了一番还是没有得到明确的答案。望各路大神指出问题~
谢谢!