C++: How to use a vector function in a class?
<p>This question - <em>Two Sum</em> - is from <a href="https://leetcode.com/problems/two-sum/" rel="nofollow">LeetCode</a>, and the function(algorithm) code is from <a href="https://leetcode.com/discuss/72453/o-n-c-code-which-defeats-98%25" rel="nofollow">here</a>. I used to use C++ in my undergraduate. But I have a long time not using it. I am reviewing the data structure of C++ now. I have search many and many websites to review the C++ basic knowledge. </p>

<p>Here is my code, I want to implement the algorithm I mentioned before in that question. But I don't know what is wrong with my code in the <code>main</code> part.</p>

<pre><code>int main()
{
    vector&lt;int&gt; numbers(4);
    int target;
    cout&lt;&lt;"input numbers"&lt;&lt;endl;
    for(int i=0; i&lt;4; ++i)
    cin &gt;&gt; numbers[i];
    cout&lt;&lt;"target"&lt;&lt;endl;
    cin &gt;&gt; target;
    Solution solu;
    solu.twoSum(numbers, target);
    cout &lt;&lt; solu.ans &lt;&lt; endl;//No member named 'ans' in 'Solution'
}
</code></pre>

<p>I use Xcode to run C++. Can someone help me with this question? </p>

<p>The solution <a href="https://leetcode.com/discuss/72453/o-n-c-code-which-defeats-98%25" rel="nofollow">here</a> has error, <code>Control may reach end of non-void function</code>. Is it because of Xcode compiler or it do has error in code?</p>

<p>Please explain this detailedly. 
 Thanks in advance.</p>