If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

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:

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.

Re: Function Overloading (OOP Task)

Yes, you need to supply a value to f1 as f1 is defined to require one argument of either type int, double or long. The number should be obtained before the function is called so the program knows which version of the function to use.

Code:

//f1 requires a value
cout << f1();

In relation to your program to overload a function to print first one and then two integers, you could do something like this

Re: Function Overloading (OOP Task)

Thank you 2kaud for your help. To answer the previous post. 2kaud has certainly not "done my homework for me", in fact i fail to see how this is even a good example of overloading when they are both integers? It will certainly help me though. Thanks again.

Re: Function Overloading (OOP Task)

Originally Posted by mehmehspazumweh

Thank you 2kaud for your help. To answer the previous post. 2kaud has certainly not "done my homework for me", in fact i fail to see how this is even a good example of overloading when they are both integers? It will certainly help me though. Thanks again.

"I have been asked to create a program to overload a function which should accept and print first one integer and then two integers."

Re: Function Overloading (OOP Task)

yeah fair enough. i didnt quite explain the full program expected of me so it that sense you are right... he did do it for me... but thats not all i have to do. this example will help but as i said he hasnt done all the work. thanks again.

Generally, members of this forum will be reluctant to do your homework for you. Here are some reasons:

In a very general sense, it is counter-productive to do homework for others. The very purpose of your homework is to verify that you have understood a subject and are able to apply the learned knowledge to solving specific problems. By having someone else do the assignment for you, you are not only cheating at your teachers, but also at yourself, since you pretend (and perhaps even believe) to have acquainted knowledge and skills that you actually don't have.
...
Don't expect to lean back and have others do the work for you.

Re: Function Overloading (OOP Task)

Right... OK. This will be my last post on this thread because quite frankly you're being very unfair and I don't particularly care for your opinion any longer. You seem to have not realized that i did actually produce my own code? I asked to be "pointed in the right direction". Honestly... how could you possibly think i am expecting fully working code as a response to my perfectly reasonable question? The fact that the response was indeed working code gives you no right to assume that I don't understand it or will maybe attempt to pass it off as my own. I understand the purpose of homework for crying out loud, don't patronize me. I was only stuck on one line of code which i am now able to resolve and continue working on thanks to the help of 2kaud. Jeez

Re: Function Overloading (OOP Task)

Originally Posted by mehmehspazumweh

Right... OK. This will be my last post on this thread because quite frankly you're being very unfair and I don't particularly care for your opinion any longer. You seem to have not realized that i did actually produce my own code? I asked to be "pointed in the right direction". Honestly... how could you possibly think i am expecting fully working code as a response to my perfectly reasonable question? The fact that the response was indeed working code gives you no right to assume that I don't understand it or will maybe attempt to pass it off as my own. I understand the purpose of homework for crying out loud, don't patronize me. I was only stuck on one line of code which i am now able to resolve and continue working on thanks to the help of 2kaud. Jeez

My posts weren't directed to you. 2kaud didn't actually address your question, but gave you a complete solution to your homework, which isn't the way the board operates. Your problem really wasn't about overloading but about how to call functions correctly.

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.