I'am very new to learning C++ but I like it, basically I'm trying to create a simple code where if I write for example the word Cheese it will translate it in my language(Macedonian)
Here's the code but I get errors could someone help me out what I need to fix ?
Also please if you could use the simplest method because as I said I'm still very new.
Thanks
#include <cstdlib>
#include <iostream>
#include <string>
usingnamespace std;
class Dictionary {
public:
void cheese() {
if (a=="cheese")
cout <<"Sirenje"<<endl;
}
}
int main(int argc, char *argv[])
{
Dictionary dictionarywords;
string a;
cout<<"What word would you like to translate from English to Macedonian?"<<endl;
cin>>a;
dictionarywords.cheese();
system("PAUSE");
return EXIT_SUCCESS;
};
and here are the errors I'm getting
Untitled1.cpp: In member function `void Dictionary::cheese()':
Untitled1.cpp:11: error: `a' undeclared (first use this function)
Untitled1.cpp:11: error: (Each undeclared identifier is reported only once for each function it appears in.)
Untitled1.cpp: At global scope:
Untitled1.cpp:17: error: new types may not be defined in a return type
Untitled1.cpp:17: error: extraneous `int' ignored
Untitled1.cpp:17: error: `main' must return `int'
You've declared string a; as local in main (line 19).
Your member function cheese can't see a local variable in main.
You need to pass it as an argument to cheese.