Convert number into words I am trying to implement a program which can convert number into words. My code can convert numbers between 0 - 999.  It uses recursive function calls and simple arithmetic operations. Can you please review it and give me your feedback?

I used three different vectors to store words such as "Six" and "Eleven" and then access there indexes according to your input.

numberToWord.h

#ifndef numberToWord_H
#define numberToWord_H

#include &lt;vector&gt;
#include &lt;string&gt;

class numbertoword
{
public:
    numbertoword();
    ~numbertoword(){};

public:
    std::vector&lt;std::string&gt; one2nine;
    std::vector&lt;std::string&gt; elevent2ninteen;
    std::vector&lt;std::string&gt; twoDigit;
    std::vector&lt;std::string&gt; threeDigit;

public:
    void initialize();
    void convert(int number);
    int countNumber(int number);
    void calculate(int number, int count);
    void display(int digit);

private:
    int xN, yN;
    int originalNumber;

};



#endif


Source.cpp

#include &lt;iostream&gt;
#include "numberToWord.h"

numbertoword::numbertoword() : xN(0), yN(0), originalNumber(0)
{
}

void numbertoword::initialize()
{
    //one to nine
    one2nine.push_back("Zero");
    one2nine.push_back("One");
    one2nine.push_back("Two");
    one2nine.push_back("Three");
    one2nine.push_back("Four");
    one2nine.push_back("Five");
    one2nine.push_back("Six");
    one2nine.push_back("Seven");
    one2nine.push_back("Eight");
    one2nine.push_back("Nine");

    //eleven to ninteen
    elevent2ninteen.push_back("Eleven");
    elevent2ninteen.push_back("Twelve");
    elevent2ninteen.push_back("Thirteen");
    elevent2ninteen.push_back("Fourteen");
    elevent2ninteen.push_back("Fifteen");
    elevent2ninteen.push_back("Sixteen");
    elevent2ninteen.push_back("Seventeen");
    elevent2ninteen.push_back("Eighteen");
    elevent2ninteen.push_back("Nineteen");

    //TwoDigit
    twoDigit.push_back("Ten");
    twoDigit.push_back("Twenty");
    twoDigit.push_back("Thirty");
    twoDigit.push_back("Forty");
    twoDigit.push_back("Fifty");
    twoDigit.push_back("Sixty");
    twoDigit.push_back("Seventy");
    twoDigit.push_back("Eighty");
    twoDigit.push_back("Ninety");

    //threeDigit
    threeDigit.push_back("Hundred");
}

void numbertoword::display(int digit)
{
    if( originalNumber &lt; 10)
    {
        std::cout&lt;&lt; one2nine[digit]&lt;&lt;" ";
    }
    else if( originalNumber &lt; 20)
    {
        std::cout&lt;&lt; elevent2ninteen[digit - 1]&lt;&lt;" ";
    }
    else if( originalNumber &lt; 100)
    {
        std::cout&lt;&lt; twoDigit[digit - 1]&lt;&lt;" ";
    }
    else if( originalNumber &lt; 1000)
    {
        std::cout&lt;&lt;one2nine[digit]&lt;&lt;" "&lt;&lt;threeDigit[0]&lt;&lt;" ";
    }
}

void numbertoword::calculate(int number, int count)
{
    if( number &lt; 10)
    {
        display(number); return;
    }

    xN = number / count;    
    yN = number - (xN * count);

    if( number &lt; 20 &amp;&amp; number != 10)
    {
        display (yN ); return;
    }
    else if(number &lt; 100 &amp;&amp; yN == 0)
    {
        display( xN ); return;
    }
    else if(number &lt; 100 )
    {
        display( xN );
    }
    else if(number &lt; 1000 &amp;&amp; yN == 0)
    {
        display(xN);
        return;
    }
    else if(number &lt; 1000 )
    {
        display(xN);
    }
    originalNumber = yN;
    count = countNumber(originalNumber);
    calculate(yN, count);


}

int numbertoword::countNumber(int number)
{
    int c = 1;
    while( number &gt; 9)
    {
        number = number / 10;
        c *= 10;
    }

    return c;
}

void numbertoword::convert(int number)
{
    initialize();

    originalNumber = number;

    int c = countNumber(number);
    calculate(number, c);

}

int main()
{
    numbertoword n2w;
    n2w.convert(999);

    std::cin.get();
    return 0;
}
numberToWord.h


Consider renaming numbertoword to NumberToWord.  This uses a naming convention referred to as PascalCase, which is different from your variables and functions.  Also notice that the compound words have been emphasized.  This makes it easier for others to read the full name.
Since you're not using your own destructor, you can just leave it out.  The compiler will provide one for you that should be suitable.
These names make no sense to me:


int xN, yN;



Unless these shortened names are obvious in the program, they should be spelled-out entirely so that others can understand them.  It may also benefit you in case you ever forget what they mean.


Source.cpp


Elaborating on what @vnp has mentioned about initializer lists, you can use it in place of the multiple calls to push_back():

one2nine { "one", "two", "three" /* ... */ };


Moreover, consider renaming the vector to oneToNine, which is less-awkward of a name.  Apply this to the other similar names as well.

Better yet (regarding the use of vectors), you can use std::array instead.  It would be better-suited for this task as you're not needing a dynamic data structure here.
This can be simplified:


number = number / 10;



by using the /= operator:

number /= 10;

With the existing curly braces, these should be on separate lines:


display(number); return;


You should be doing input-validation with this.  If the user inputs a non-numerical value or a value below 0 or above 999, the program should display an appropriate error message and then terminate.
This program can be made more usable by accepting command line arguments:

int main(int argc, char* argv[])
{
    int number;

    // the file name is considered an argument
    if (argc &gt; 1)
    {
        number = std::atoi(argv[1]);
    }
    // only file name given
    else if (argc == 1)
    {
        std::cin &gt;&gt; number;
    }

    // ...
}


(std::atoi() requires &lt;cstdlib&gt;)
It would make more sense to construct numbertoword objects with the original number, rather than passing it to convert().  The function has no business doing that, and this initialization should only be done by the constructor.  The function should also no longer take arguments.

numbertoword n2w(999);
n2w.convert();


In order for this to work, you should replace the default initializer list with one that takes an argument:

numbertoword::numbertoword(int originalNumber)
    : xN(0)
    , yN(0)
    , originalNumber(originalNumber)
{}


(I've rearranged the list so that it's easier to maintain the data members.)