I'm taking an intro course to C++ and we're covering stack overload and how the library and linker come into play with programming.
I have a simple .cpp file called dataType.cpp. The code is as follows
int A;
int rtn;
int main()
{
rtn = dataType(A);
cout << rtn << "\n";
return rtn;
};
we're supposed to write a function that returns an integer. If the parameter is a long double return a value of 1, if its a double return a value of 2, a float should return a value of 3, an unsigned long integer should return a value of 4, long integer 5, unsigned integer 6, integer 7, unsigned short integer 8 etc.
Now......I believe that the header file is basically my function. But if my .cpp says to simply return a value - i guess I'm not sure what my header should say?? To me it seems as if the function already exists in the .cpp file?
do i need to declare the long integer, double, integer, float etc.? I have no clue what i should be puttin g in this header file and would appreciate any help
what i want to put in the header file is something like this
int (long double dataIn);
for each of my data types. But i don't feel like i'm on the right track.
To me, this looks like the function because the variables are declared and then we go into the main function inside the braces. I am going to display on the screen the return value of dataType(A).