0

嘿伙计们,我想我真的很亲密,但我不太确定如何继续。所有与我的问题相关的问题都没有真正回答任何问题。我现在遇到的错误是

(33): error C2064: term does not evaluate to a function taking 1 arguments
(41): error C2064: term does not evaluate to a function taking 1 arguments

头文件:

using namespace std;

class romanType
{
public: 
    void printRoman(char romanNum);
    int printDecimal(int& total);
    int convertRoman(int& total);
    void setRoman(char& roman);

    romanType();
    romanType(char);

private:
    char romanNum[6];
    int decimal;
    int total;
};

执行:

#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include "romanType.h" 

using namespace std;

romanType::romanType(char)
{

};
void romanType::printRoman(char romanNum)
{
    cout << "Here is your number in Roman Numeral form: " << romanNum << endl;
};

int romanType::printDecimal(int& total)
{
    cout << "Here is your number in Decimal form: " << total << endl;
    return total;
};

void romanType::setRoman(char& romanNum)
{

};
int romanType::convertRoman(int& total)
{
    int len = 0;
    len = strlen(romanNum);
    int count[1];

     for(int i = 0; i < len; i++)
     {           
           switch(romanNum[i])
           {
                 case 'M':
                      count[i] = 1000;
                      break;
                 case 'm':
                      count[i] = 1000;
                      break;
                 case 'D':
                      count[i] = 500;
                      break;
                 case 'd':
                      count[i] = 500;
                      break;
                 case 'C':
                      count[i] = 100;
                      break;
                 case 'c':
                      count[i] = 100;
                      break;
                 case 'L':
                      count[i] = 50;
                      break;
                 case 'l':
                      count[i] = 50;
                      break;
                 case 'X':
                      count[i] = 10;
                      break;
                 case 'x':
                      count[i] = 10;
                      break;
                 case 'V':
                      count[i] = 5;
                      break;
                 case 'v':
                      count[i] = 5;
                      break;
                 case 'I':
                      count[i] = 1;
                      break;
                 case 'i':
                      count[i] = 1;
                      break;
                 default:
                      cout << "Error.." << endl;
           }   
           total = total + count[0];
     }
     return total;
};

我的主要:

#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include "romanType.h"

using namespace std;

int main()
{
    romanType r;

    char romanNum;
    char choice;
    int decimal;
    int total;

    cout << "Hello! Please enter your Roman Numeral: " << endl; 
    cin >> romanNum; 
    cout << endl;


    r.setRoman(romanNum);
    r.convertRoman(total);

    cout << "Do you want the Roman Numeral or the Decimal?" << endl;
    cout << "Press [D] for Decimal!" << endl << "Press [R] for Roman Numeral!" << endl;

    cin >> choice;

    if (choice == 'D' || choice == 'd')
         r.printDecimal(total);
    else if (choice == 'R' || choice == 'r')
         r.printRoman(romanNum);
    else
        cout << "That wasn't the right button!" << endl;

    system ("pause");
    return 0;
}

我很确定我在正确的轨道上。很高兴看到与我的错误有关的任何提示或建议。

提前致谢

4

1 回答 1

-1

快速浏览一下代码,我可能会建议在调试窗口中查看每一步的变量值。我看到的是两个变量,一个名为 romanNum 的 char 类型,以及一个完全不同的名为 romanNum 的 char 数组。它有点令人困惑,但如果您只向用户询问罗马数字中的单个字符,那么您根本不需要数组。否则,您可以获得一个字符串,然后将其转换为数组。

从那里开始,看看是否有帮助。

于 2013-08-28T19:43:29.080 回答