I've not compiled this code and even not programmed C++ for a long time.
Please check this.
The program will be something like -
Code:
include <iostream>
class factorial
{
long int fact=1;
factorial (int no) // This is a constructor with 1 argument
{
int store=no;
for ( ; no <1 ; --no)
fact*=no;
cout << "Factorial of " << store << "is " << fact;
}
}
int main()
{
int no;
factorial f1(3); // Direct call
// User choice
cout << "Enter a number : ";
cin >> no;
factorial f(no);
return 0;
}
Sorry, if there are mistakes.