关于类中函数显示异常的问题

问题遇到的现象和发生背景

发现函数在类中显示异常

问题相关代码,请勿粘贴截图
#include<iostream>
#include<algorithm>
using namespace std;
class Solution{
    public int[] thesum(int[] nums,int target)
    {
        int n=nums.length;
        for(int i=0;i<n;++i){
            for(int j=i+1;j<n;++j)
            {
                if(nums[i]+nums[j]==target){
                    return new int[]{i,j};
                }
            }
        }
        return new int[0];
    }
}

运行结果及报错内容

error: expected unqualified-id before '[' token
public int[] thesum(int[] nums,int target)


#include<iostream>
#include<algorithm>
using namespace std;
class Solution {
public:
    int* thesum(int nums[], int target)
    {
        int n = sizeof(nums);
        for (int i = 0; i < n; ++i) {
            for (int j = i + 1; j < n; ++j)
            {
                if (nums[i] + nums[j] == target) {
                    return new int[] {i, j};
                }
            }
        }
        return nums;
    }
}

https://leetcode-cn.com/problems/two-sum/solution/liang-shu-zhi-he-by-leetcode-solution/