Ask your own question, for FREE!
Computer Science 14 Online
OpenStudy (anonymous):

hi everyone...can i ask question a liltle bit about class in c++..i really have problem in coding my programme...i got errors at here : int calcFactorial::calcSum(int one, int two, int three) { cout<<"enter a positive integer"<>num; fact=((num*factorial)(num-1)) ; cout<<"sum:"<

OpenStudy (anonymous):

What are the error messages? Are `num' and `factorial' global? They aren't defined within the method, so that may be the issue. A possible ZeroDivison Error can occur when num is equal to 1, in the line `fact = ((num*factorial)(num-1));'

OpenStudy (anonymous):

are `num' and `fact' declared ** typo sorry (I said factorial instead of fact )

OpenStudy (rsmith6559):

fact, factorial and num ( in the posted code ) aren't defined properly. A class is it's own namespace, so cout and cin aren't defined, you probably want std::cout, std::endl and std::cin. one, two and three aren't used, that's probably just a warning. In the line: fact=((num*factorial)(num-1)) ; there's no operator between the two sets of inner parentheses.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!