形参表不匹配(BUG)
在您的代码中,存在两个主要问题导致"形参表中不匹配"的错误:
erase()
函数中的成员变量名错误
iterator erase(iterator pos) {// ...size--; // ❌ 错误:成员变量名为 _size 而非 sizereturn iterator(next); }
修正:
iterator erase(iterator pos) {// ..._size--; // ✅ 改为正确的成员变量名 _sizereturn iterator(next); }
形参表不匹配的常见情况
成员变量名拼写错误
(如本例中的size
vs_size
)函数签名不一致
// 声明 void func(int a, double b);// 定义 void func(int a) { ... } // ❌ 参数数量不匹配
类型不兼容
void process(std::string s);process(10); // ❌ int 无法转为 string
const 限定符缺失
// 声明 void print(const vector<int>& v);// 定义 void print(vector<int>& v) { ... } // ❌ 缺少 const
模板实例化失败
template<typename T> T add(T a, T b) { return a + b; }add(5, 3.14); // ❌ T 无法同时匹配 int 和 double
函数重载歧义
void calc(float x); void calc(double x);calc(10); // ❌ int 可转为 float/double,产生歧义