Error String does Not name a Type

Hello I have a project that needs an input parser. I keep getting an error and cannot find the problem.
it has been a while since i wrote in C++ and i am not even sure that what i have will work but i cant find out until i get rid of my
error: 'string' does not name a type
the *** show the error line
1
2
3
4
5
6
7
8
9
10
11
#include "inputParse.h"

**std::string inputParse::aAParse(const std::string& userInput, std::string delimiter)
**{
    //find the delimiter
    pos = userInput.find_first_of(delimiter);
    //find where delimiter ends
    lastPos = userInput.find_first_not_of(delimiter);
    //return the string in between the pos lastPos markers
    return userInput.substr(pos, (lastPos - pos));
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#pragma once
#include <string>
#include <iostream>

using namespace std;

class inputParse
{
    public:
       std::string aAparse(const std::string& userInput, std::string delimiter);

    private:
        std::string tempString;

        size_t pos, lastPos;
};


I dont understand where string is not named.
Last edited on
missing semicolon on line 16
missing the ; won't result in that error....but failing to use std::string instead of string in a file where it is not explicitly said using using would...in this case your header file.
I don't know if it is a better idea to #include <string> . in the header file. Anyone?
I have tried replacing all strings with std::string and commenting out the using namespace std;

it did not work but new error on line 4

no std::string inputParse::aAParse(blah) function declared in inputParse
seems you need to include some files
Be careful with your naming conventions. Method declaration:

std::string aAparse(const std::string& userInput, std::string delimiter);

Method definition:

std::string inputParse::aAParse(const std::string& userInput, std::string delimiter)

Notice the different names. One has a lower case 'p', while the other has an upper case one.
something important is not to put any imported code #include "any.h" before the "using namespace std" sentence.

Hope this help!
Topic archived. No new replies allowed.