I'm trying to call the vector function 'twoSum' which is inside the class 'Solution' but is giving me 'Expected variable name or 'this' in lambda capture list' error when I'm trying to call the function.
Here's the code:
#include <iostream>
#include <list>
#include <vector>
using namespace std;
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
for (int i=0; i+1<=nums.size(); i++){
if ((nums[i] + nums[i+1]) == target){
//cout << "[" << i << i+1 << "]";
return (i,i+1);
}
}
return {2, 3};
}
};
int main()
{
Solution solobject;
solobject.twoSum([1,2],2); //Not Calling function
return 0;
}
What am I doing wrong?