0

Just because you return them in a previous function doesn't mean the next function gets access to them. You have to pass those variables to these functions if you want to use them.

0

since I have changed the implement section a bunch trying to clear errors Ill post the revised code now:

#include <cstdlib>
#include <iostream>
#include <string>
#include <fstream>
#include "KeyPad.h"
//Class Implementation

void read_file ()
{
   
   ifstream inFile("USdictionary.txt");
   if (inFile.fail())
{
      cout << "\nThe file was not opened successfully, please check"
              "\the file exists. " << endl;
      exit (1);
}
}  

       


void KeyPad::readnumbers ()
{
     cout << "Enter numbers you wish to convert." << endl;
     cin >> nums;
}
void KeyPad::check_numbers ()
{
   if  (nums.find("1", 0))
       cout << "Then number 1 does not corrospond to a letter on a standard"
               "keypad." << endl;
   if (nums.find("0", 0))
      cout << "The number 0 does not correspond to a letter on a standard"
              "keypad." << endl;
exit (1);
}
void KeyPad::readwords()
{
     cout << "Enter words you wish to convert to numbers.";
     cin >> words;
    
}

    
char KeyPad::convert_words_to_nums(string)
{

int num;
char yourChar, stringW, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

     
    if( yourChar == a || yourChar == b || yourChar == c)
{
 num=2;
}
if( yourChar == d || yourChar == e || yourChar == f)
{
 num=3;
}
if( yourChar == g || yourChar == h || yourChar == i)
{
 num=4;
}
if( yourChar == j || yourChar == k || yourChar == l)
{
 num=5;
}
if( yourChar == m || yourChar == n || yourChar == o)
{
 num=6;
}
if( yourChar == p || yourChar == q || yourChar == r || yourChar == s)
{
 num=7;
}
if( yourChar == t || yourChar == u || yourChar == v)
{
 num=8;
}
if( yourChar == w || yourChar == x || yourChar == y || yourChar == z)
{
 num=9;
}
     return stringW;}

char  KeyPad::convert_nums_to_words(string)
{
char yourChar, stringN, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;
int yourNum;
if ( yourNum == 2 )
{
     yourChar == a || b || c;    
}
if ( yourNum == 3 )
{
     yourChar == d || e || f;
}
if ( yourNum == 4 )
{
     yourChar == g || h || i;
}
if ( yourNum == 5 )
{
     yourChar == j || k || l;
}
if ( yourNum == 6 )
{
     yourChar == m || n || o;
}
if ( yourNum == 7 )
{
     yourChar == p || q || r || s;
}
if ( yourNum == 8 )
{
     yourChar == t || u || v;
}
if ( yourNum == 9 )
{
     yourChar == w || x || y || z;
}
    return stringN;}

void KeyPad::disp_message_words ()
{
       cout << stringW << endl;
       
}
void KeyPad::disp_message_nums ()      
{
     cout << stringN << endl;
       
}
0

& means "pass by reference". There is no need for that here:

void KeyPad::disp_message_nums (string stringN)      
{
     cout << stringN << endl;
       
}
0

Alright believe it or not I got all my errors cleared in the implementation file. (with a lot of your help of course).
The remainder of my errors are in the main function.

#include <cstdlib>
#include <iostream>
#include <string>
#include "implement.cpp"
using namespace std;



    int main ()
{
    int num, word;
    KeyPad X1, X2, W1, N1, M1, M2;
    num = X1.readnumbers ();
    cout << "Your entered message in numbers is " << num << endl;
    W1.convert_nums_to_words ();
    cout << "Your entered message in words is "  << words << endl;
    N1.convert_words_to_nums ();
    cout << "Your message converts to " << endl;
    M1.disp_message_nums();
    cout << "Your message converts to " << endl;
    M2.disp_message_words();
     
    system("PAUSE");
    return EXIT_SUCCESS;
}

errors:
13 C:\Dev-Cpp\main.cpp void value not ignored as it ought to be
15 C:\Dev-Cpp\main.cpp no matching function for call to `KeyPad::convert_nums_to_words()'
note C:\Dev-Cpp\implement.cpp:88 candidates are: char KeyPad::convert_nums_to_words(std::string)
16 C:\Dev-Cpp\main.cpp `words' undeclared (first use this function)
17 C:\Dev-Cpp\main.cpp no matching function for call to `KeyPad::convert_words_to_nums()'
note C:\Dev-Cpp\implement.cpp:47 candidates are: char KeyPad::convert_words_to_nums(std::string)
19 C:\Dev-Cpp\main.cpp no matching function for call to `KeyPad::disp_message_nums()'
21 C:\Dev-Cpp\main.cpp no matching function for call to `KeyPad::disp_message_words()'

0

No matching function call means the arguments you are passing are not what the function expects. In this case you are passing nothing () and you are supposed to be passing a string.

Void value not ignored means you are assigning the "output" of a void function to a variable.

num = X1.readnumbers ();

doesn't make sense if readnumbers() is void.

0

Fixed everything except a bunch of expected primary-expression before')' token
errors. revised code:

int main ()
{
    int num, words;
    KeyPad X1, X2, W1, N1, M1, M2;
    num = X1.readnumbers (string);
    cout << "Your entered message in numbers is " << num << endl;
    W1.convert_nums_to_words (string);
    cout << "Your entered message in words is "  << words << endl;
    N1.convert_words_to_nums (string);
    cout << "Your message converts to " << endl;
    M1.disp_message_nums(string);
    cout << "Your message converts to " << endl;
    M2.disp_message_words(string);
     
    system("PAUSE");
    return EXIT_SUCCESS;
}
0

This doesn't make sense:

num = X1.readnumbers (string);

You have to pass it a variable:

string a;
num = X1.readnumbers (a);
0

I am still getting an error for
19 C:\Dev-Cpp\main.cpp no matching function for call to `KeyPad::readnumbers(std::string&)'
and a note:
note C:\Dev-Cpp\implement.cpp:24 candidates are: void KeyPad::readnumbers()

1

Learn to trust the compiler! That says you are passing a string to readnumbers, but it is expecting nothing to be passed.

0

if I get rid of the "a" i get error:
19 C:\Dev-Cpp\main.cpp argument of type `void (KeyPad::)()' does not match `int'

1

This has gone on much too long. You need to read a c++ tutorial to understand parameters and arguments and then give it another shot. I don't understand how you can expect to write something in a language that you do not know? If I gave you a German/English dictionary and asked you to write an essay, of course you would not be able to do it. Here you are trying to write an essay in c++, but you don't know the language!

Votes + Comments
Yes
0

You are 100% right. The German analogy is good. For me it was like walking into German 101 and the professor speaking in nothing but German. I guess I'll turn in what I have and beg for mercy. Thank you very much for your help.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.