Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have just started programming and I am learning C++ on my own. I've been studying about functions for two days now and although I have not had much problems with the theory, but coding programs using functions has been pretty difficult for me. Can anybody suggest online resources where I could find related study materials + examples and questions ?
Posted
Comments
Sergey Alexandrovich Kryukov 30-Jun-15 11:04am    
It makes little sense. You don't need extra resource, you need learn harder. If you did not master function, you did not learn anything at all. You just need to learn more, spend more time. I hope you have some manual and a compiler, so what else would you need?

You did not tell us what exactly seems to be difficult, so we hardly can help more. If you need help, you need to be more specific.

—SA

1 solution

Functions aren't difficult to use, not really - when you get your head around the idea.
Have a look at these:
http://www.cplusplus.com/doc/tutorial/functions/[^]
http://www.tutorialspoint.com/cplusplus/cpp_functions.htm[^]
http://www.functionx.com/cpp/Lesson05.htm[^]
They go into details of how to use them.

The basic idea is that a function is a set of instructions that you can use to perform a task, and that you can pass parameters to that tell it what to perform the task on.
If you think about it, you use them in the "real world" all the time, but you don;t formalize them into "functions" - instead we call them "skills", or "abilities", or "can do's". Two simple examples are making a sandwich, and drivign a car.

You know how to make a sandwich: butter the two slices of bread, put the filling on the bottom slice, and put the top slice on. Cut in half to make it easier to eat.
That's a function:
C++
Food MakeSandwich(Filling f) { ... }
You pass it the filling (ham, beef, cheese, peanut butter...) and it doesn't matter particularly what the filling is within the function.

Driving a car is a skill: but once you have it all you have to do is pass it a destination or a route as the parameter and you cope with the rest under the "driving" function. The actual destination (parameter) is irrelevant to the mechanics or gear selection, throttle control, observation, and so on.

Make sense?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900