Functions

***
Last edited on
line 6 = line 39 ....
line 7 = line 71 ....
line 8 = line 107 ...
line 9 = line 110 ...
line 10 = line 113...
Last edited on
***
Last edited on
http://www.cplusplus.com/doc/tutorial/functions/

duplicate declaration function.
declaration on main.
is c++.
Last edited on
closed account (iN6fizwU)
Well, you are currently prototyping quite a lot of functions in the middle of your main() routine.

Perhaps you could try thinking of functions as individual chapters of a reference book.
Your list of function prototypes goes at the start (like a contents index).
Each "function" is then like a separate chapter - you can't put one chapter inside another.

I would write this code slowly, from scratch, entering one new function at a time, rather than trying to write the whole in one go.


for calling a function you have to eliminate the function type in the main
otherwise in your code do not make sense two function declarations
***
Last edited on
in these lines, you create function prototypes, but I do not see the definition of the functions, that is, when they are called those functions do not produce any effect as they have no code inside (if the compiler will accept them)
***
Last edited on
i think do you want this but please read the link:

http://www.cplusplus.com/doc/tutorial/functions/

this is an example of a function declaration but must be done outside the main function. regarding the purpose of your program I can not help you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
double displayMenuGetValidPassType()
{
        std::cin >> passType ; // insert the value for var passType
        switch (passType)
        {
            case 1:
                baseCost = OP;
                passName = "One Park One Day Pass";
                break;
            case 2:
                baseCost = PH;
                passName = "Park Hopper Pass";
                break;
            case 3:
                baseCost = PHWP;
                passName = "One Park One Day Pass with Water Part Option";
                break;
            case 4:
                baseCost = PHWP;
                passName = "Park Hopper Pass with Water Park Option";
                break;
            case 5:
                amtDue = AP;  //supposed to be done in main, but you are stupid and dont know how to do this
                baseCost = AP;
                passName = "Annual Pass";
                numDays = 365;
                break;
            default:
                validPassType = false;
                break;
        }

        return ??? (double type)

}
***
Last edited on
Topic archived. No new replies allowed.