У меня есть следующий код:
#ifndef CURRENCY_H_
#define CURRENCY_H_
class currency
{
public:
enum signType {plus, minus};
currency(signType theSign = plus, unsigned long theDollars = 0, unsigned int theCents = 0);
~currency(){};
void setValue(signType, unsigned long, unsigned int);
void setValue(double);
signType getSign() const {return sign;};
unsigned long getDollars() const {return dollars;};
unsigned int getCents() const {return cents;};
currency add(const currency&) const;
currency& increment(const currency&);
void output() const;
private:
signType sign;
unsigned long dollars;
unsigned int cents;
};
#endif
Реализация конструктора и метода setValue:
currency::currency(signType theSign, unsigned long theDollars, unsigned int theCents)
{
setValue(theSign, theDollars, theCents);
}
void currency::setValue(signType theSign, unsigned long theDollars, unsigned int theCents)
{
if(theCents > 99)
throw invalid_argument("Cents should be < 100");
this.sign = theSign;
dollars = theDollars;
cents = theCents;
}
Когда я пытаюсь создать объект валюты, например:
currency cur = currency(minus, 2, 25);
Я получил ошибку:
error: expected primary-expression before ‘(’ token
Я могу создать пустой объект валюты (без ошибок), например:
currency cur;
но когда я вызываю метод setValue:
cur.setValue(minus, 2, 25);
ошибка появляется снова:
error: missing template arguments before ‘,’ token
Любой совет / идея?