开发者

string as parameter in a function

开发者 https://www.devze.com 2023-04-07 03:20 出处:网络
i wrote a function to search if its parameter is in a given table obtab1.txt....the optab table has two columns out of which the parameter can only be in the first column..开发者_开发百科..in the avia

i wrote a function to search if its parameter is in a given table obtab1.txt....the optab table has two columns out of which the parameter can only be in the first column..开发者_开发百科..in the aviasm.h file i wrote this code....

class aviasm
{
public:
   aviasm(char *,char *);
   ~aviasm();

   void crsymtab();
   bool in1(string );

}

In the aviasm.cpp file i wrote...

bool aviasm::in1(string s)
{
ifstream in("optab1.txt",ios::in);//opening the optab1.txt
char c;
string x,y;
while((c=in.get())!=EOF)
{
    in.putback(c);//putting back the charcter into stream
    in>>x;//first field
    in>>y;
    if(x==s)
        return true;
    else 
        return false;
}
}

but i encountered several errors on compiling....

'bool aviasm::in1(std::string)' : overloaded member function not found in 'aviasm'
'aviasm::in1' : function does not take 1 arguments
'syntax error : identifier 'string'

...can anybody help??


It appears as though you are trying to use string without the proper declarations, you will need this at the top of your file:

#include <string>
using std::string;
0

精彩评论

暂无评论...
验证码 换一张
取 消