How to use class vector correctly in VS 2022?

潇 冯 0 Reputation points
2023-10-30T05:41:03.9966667+00:00

When I try to use vector.size() and .push_back , it tells me "class std::vector has no member "size"".

I have use #include<vector> and using namespace std.

This issue does not exist when I compile the same code Using VS Code.

屏幕截图 2023-10-30 132851

屏幕截图 2023-10-30 133854

屏幕截图 2023-10-30 133913

Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other
A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.