I'm working on a program for class that takes in a number from 0 to 9999, and spits out the word value (ie 13 would be spit out as "thirteen", etc) And I'm having a pain with the array for some reason.
Here is the class so far:
#include<iostream>
#include<string>
using namespace std;
class Numbers
{
private:
int number;
string lessThan20[ ] = {"zero", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen",
"fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
string incrementsOfTen[ ] = {"twenty", "thirty", "fourty", "fifty", "sixty",
"seventy", "eighty", "ninety"};
string hundred = "hundred";
string thousand = "thousand";
public:
Numbers(int newNumber)
{
setNumber(newNumber);
}
void setNumber(int newNumber)
{
if(newNumber < 0 || newNumber > 9999)
{
cout << "Number cannot be negative or larger than 9999, defaulted to zero." << endl;
number = 0;
}
else
{
number = newNumber;
}
}
int getNumber()
{
return number;
}
};
My issue is up at the two string arrays, I'm getting these errors back from my compiler:
1>f:\college work\csis 297\assignment 4\chapter 11-1\chapter 11-1\11-1.cpp(19) : error C2059: syntax error : '{'
1>f:\college work\csis 297\assignment 4\chapter 11-1\chapter 11-1\11-1.cpp(19) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>f:\college work\csis 297\assignment 4\chapter 11-1\chapter 11-1\11-1.cpp(22) : error C2059: syntax error : '{'
1>f:\college work\csis 297\assignment 4\chapter 11-1\chapter 11-1\11-1.cpp(22) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>f:\college work\csis 297\assignment 4\chapter 11-1\chapter 11-1\11-1.cpp(24) : error C2864: 'Numbers::hundred' : only static const integral data members can be initialized within a class
1>f:\college work\csis 297\assignment 4\chapter 11-1\chapter 11-1\11-1.cpp(25) : error C2864: 'Numbers::thousand' : only static const integral data members can be initialized within a class
I'm sure if I spend more time on the single variable strings I can figure those out, but I've spent the better part of an hour looking up what I'm doing wrong on the two arrays, any advice or information would be appreciated.
Thanks in advance.
PS: No, there is no main, haven't gotten there yet, my program has a blank main right now as I'm simply trying to get the class to compile error free for now.
EDIT for clarification:
The first two errors are on the first array, the second two errors on the second array, and the last two errors are on the non-array strings.