-
February 27th, 2013, 06:54 AM
#1
Function Overloading (OOP Task)
Hello. I am working on a small task as part of some independent study for a course i am taking. I have been asked to create a program to overload a function which should accept and print first one integer and then two integers. Here is the code i have produced so far:
http://pastebin.com/BUT9mfaf
Code:
#include <iostream>
using namespace std;
//Overloading f1 three ways
int f1(int a);
double f1(double a);
long f1(long a);
int main()
{
cout << f1();
system ("pause");
return 0;
}
//f1 for integer
int f1(int a)
{
cout << "Please enter a number: ";
cin >> a;
return a;
}
// f1 for double
double f1(double a)
{
cout << "Please enter a number: ";
cin >> a;
return a;
}
//f1 for long
long f1(long a)
{
cout << "Please enter a number: ";
cin >> a;
return a;
}
now my C++ isnt great, i'll be honest, but as far as i am aware the code should work. my only concern is the error i receive on line 12. I am certain there should be a value in the bracket but i dont know what. can you any of you C++ gurus point me in the right direction please? i just dont know what to do.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|