class Sample private: public: Sample(int i) ( n= i;} ___int add(Sample& s1, Sample& s2); int add(Sample& s1, Sample& s2) return s1.n + s2.n: int main@ f Sample s1(10), s2(20); cout <<___<< endl; return 0:横线处需要补充什么
时间: 2023-06-27 14:01:16 浏览: 79
需要补充 `add(s1, s2)`。完整的代码如下:
```
class Sample {
private:
int n;
public:
Sample(int i) { n = i; }
int add(Sample& s1, Sample& s2);
};
int Sample::add(Sample& s1, Sample& s2) {
return s1.n + s2.n;
}
int main() {
Sample s1(10), s2(20);
cout << s1.add(s1, s2) << endl;
return 0;
}
```
阅读全文