A guide to the famous printf() function in C. Shows you how to output data in several ways. The tutorial is not yet complete but will be continued soon.
C++ Function Templates C and C++ / Functions and Classes
C++ Function templates are those functions which can handle different data types without separate code for each of them. For a similar operation on several kinds of data types, a programmer need not write different versions by overloading a function. It is enough if he writes a C++ template based function. This will take care of all the data types.
Inline Functions C and C++ / Functions and Classes
Inline functions are not very important, but it is good to understand them. The basic idea is to save time at a cost in space. Inline functions are a lot like a placeholder. Once you define an inline function, using the 'inline' keyword, whenever you call that function the compiler will replace the function call with the actual code from the function.
Introduction to Functions C and C++ / Functions and Classes
A function is an assignment or a task that must be performed to complement the other part of a program. There are two kinds of functions: those supplied to you and those you will be writing. The functions that are supplied to you are usually in three categories: those built-in the operating system, those written in C++ and those supplied with your programming environment. The use of these functions is the same regardless of the means you get them; you should know what a function looks like, how to create one, what functions are already available, where they are located, and what a particular function does, how and when to use it.
Pointers and Functions C and C++ / Functions and Classes
Learn: Reviewing Functions, Declaring a Pointer to Function, Using a Pointer to Function, A Pointer to a Function as Argument, Passing a Function as Argument, An Array of (Pointers to) Functions, Using an Array of Functions and more.
Exploring Functions C and C++ / Functions and Classes
When a function receives an argument, it performs one of two actions with regards to the value of the argument; it might modify the value itself or only use the argument to modify another argument or another of its own variables. If you know that the function is not supposed to alter the value of an argument, you should let the compiler know. This is a safeguard that serves at least two purposes. First, the compiler will make sure that the argument supplied stays intact; if the function tries to modify the argument, the compiler would throw an error, letting you know that an undesired operation took place. Second, this speeds up execution.
The Methods of a Class C and C++ / Functions and Classes
The primary motivation of using classes in a program is to create objects as complete as possible. An object must be able to handle its own business so that the other objects of the program or of another program would only need to know which object can take care of a particular need they have. A regular variable, as a member of an object, cannot handle assignments. This job is handled by particular functions declared as members of a class. A function as a member of a class is also called a Method. On this site, the words "method" and "function", when associated with a class, will refer to the same thing: a member function of the class.
Functions (II) C and C++ / Functions and Classes
Until now, in all the functions we have seen, the arguments passed to the functions have been passed by value. This means that when calling a function with parameters, what we have passed to the function were copies of their values but never the variables themselves.
Basic C++ Functions C and C++ / Functions and Classes
Functions are bits of code that the program jumps to in order to do certain tasks. The main function holds the main code (the code that is executed first) and where the other functions are called from. Variables can be passed into and returned from a function.
Object Construction and Destruction C and C++ / Functions and Classes
In order to further customize the behavior of an object, you should make sure that it completely controls its member variables. An object should "know" what kind of values its variables hold and what values are not acceptable. As a starting point, when calling an object from another function, you should know what value a particular member is holding, before performing any operation. To solve this problem, one solution is to provide a special function that would initialize the member variables.
Recursion C and C++ / General Development
Recursion is a programming technique that allows the programmer to express operations in terms of themselves. In C++, this takes the form of a function that calls itself. A useful way to think of recursive functions is to imagine them as a process being performed where one of the instructions is to "repeat the process".
Using header files in C++ .NET C and C++ / Getting Started
This tutorial will show you how to work with C++ .NET headers (or includes). How to create a header file with a class in it, include the file in a typical .cpp file, set a variable and call a public function, both defined inside the header.
Using Templates in C++ C and C++ / Functions and Classes
Learn how class and function templates can be used to increase readability and reduce code typing.This tutorial shows you how to reuse code, save typing time, prevent time spent on debugging and saving source-code space
Pointers to C++ Member Functions C and C++ / Pointers and References
Pointers to Member Functions are one of C++'s more rarely used features, and are often not well understood even by experienced developers. This is understandable, as their syntax is necessarily rather clumsy and obscure.
While they do not have wide applicability, sometimes member function pointers are useful to solve certain problems, and when they do apply they are often the perfect choice, both for improved performance and to make the code sensible.
The WinMain procedure C and C++ / Grapics
Every Windows programming needs a main entry point. That being said, you may be wondering what this entry point is. The main entry point for any Windows program is called WinMain. The function prototype for WinMain is a little confusing at first, but as we continue to work with it you'll notice it becomes much easier to understand. Well. we've told you what it is; now were going to show you! Here's the prototype for WinMain: