locked
error C2275: 'std::vector<_Ty>' : illegal use of this type as an expression RRS feed

  • Question

  • This is my code:

    #include "stdafx.h"

    #include <codecvt>
    #include <cstdio>
    #include <locale>
    #include <sstream>
    #include <string>
    #include <vector>
    #include <iostream>

    using namespace std;

    string toMultiByte(const wstring &original)
    {
        wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
        return converter.to_bytes(original);
    }

    int main()
    {
        string original = "This:is\nmy:tst?why I hate";
        string separators = ":? \n"

        //vector<wstring> results = splitMany(original, separators);
    vector <wstring> wordVector;
    stringstream stream(original);
        string line;

        while (getline(stream, line)) 
        {
            std::size_t prev = 0, pos;
            while ((pos = line.find_first_of(separators, prev)) != std::string::npos)
            {
                if (pos > prev)
                    wordVector.push_back(line.substr(prev, pos-prev));
                prev = pos + 1;
            }
            if (prev < line.length())
                wordVector.push_back(line.substr(prev, std::string::npos));
        }
    }

    It gives the error error C2275: 'std::vector<_Ty>' : illegal use of this type as an expression. I googled for it. There were issues like not including namespace & headers. But I have added those things. Still it's not working. I'm pointless of this error. Help me to resolve this.

    Friday, August 7, 2015 8:10 PM

Answers

  • On 8/7/2015 4:10 PM, Jeyatharsini wrote:

         string separators = ":? \n"

    Semicolon is missing


    Igor Tandetnik
    • Proposed as answer by Shu 2017 Monday, August 10, 2015 7:51 AM
    • Marked as answer by Shu 2017 Tuesday, August 18, 2015 2:28 AM
    Friday, August 7, 2015 8:23 PM