There are two ways of including a file in C using #include statement:
This command would look for the file in the current directory as well as the specified list of directories as mentioned in the include search path that might have been setup.
This command would look for the file on the specified list of directories only.
This might be known to many but I recently tried it and got it working.
Suppose you make a function in C(for example here we take a simple function which calculates the square of a number).
Its a fairly simple one and I want to add in in a library thus making its reuse possible.
(Please note I am taking a very simple scenario because the actual program is not the point of focus here, but the procedure is)
int square(int n)
Compile the file:
Compile the file in which you have written this function. Lets call it “sqr.c”. A new file called “sqr.obj” is created contained compiled code.
Add the function to Library:
Add the function to the library “maths.lib” using the following command.
C:\>tlib maths.lib + c:\sqr.obj
Please note the paths. Your paths may be different than mine!
here, maths.lib is the library and + is a switch which indicates that we want to add a new function to the library and the object file is at the given path.
Add the prototype of square() function in a header file (lets say “square.h”) This file should be included in the program where we want to use the function. we can use it as:
Thats all !
Use the function and enjoy !!
Hope it helps.
Some object-oriented languages (such as C++) support multiple inheritance, where a class can have more than one immediate parent,
inheriting functionality from each. Although powerful, this technique can be dangerous, because the inheritance hierarchy can become
Other languages, such as Java and C#, support single inheritance. Here, a class can have only one immediate parent. Although cleaner
(and easier to implement), single inheritance also has drawbacks—in the real world objects often inherit attributes from multiple sources (a
ball is both a bouncing thing and a spherical thing, for example).
Ruby offers an interesting and powerful compromise, giving you the simplicity of single inheritance and the power of multiple inheritance. A
Ruby class has only one direct parent, so Ruby is a single-inheritance language. However, Ruby classes can include the functionality of
any number of mixins (a mixin is like a partial class definition). This provides a controlled multiple-inheritance-like capability with none of