View Single Post
I like Serena
I like Serena is offline
Mar3-12, 05:58 PM
HW Helper
I like Serena's Avatar
P: 6,189
Let's see...

   ExpandedTime time;
This defines a variable named "time" of the struct type, which is ok.

   ExpandedTime &etime(time);
In C this is a syntax error, but in C++ this defines a reference-variable named "etime".
What was your intention with it?

   ExpandedTime* localTime(ExpandedTime* etime);
This declares a function named "localTime", but this is not a call.

Consider a function f that takes an integer as argument and returns an integer.
You would implement it as follows (function definition and call in main):
/* Function definition */
int f(int x)
   int y = 2 * x;
   return y;

int main()
   int a = 3;
   int y;
   int f(int x);  /* This is redundant and would be a prototype declaration of the function f */
   y = f(a);     /* This is the proper function call */

   return 0;