...
Read more

FRIEND FUNCTION A non member function may not possess an access to the private data of a class . But , there could possibly be a scenario in which we want two classes to share a specific function . To illustrate , take into account a case where two classes , supervisor and Warden , are defined . We want to use a function Salary( ) to work on the object of both these classes...
Read more

One among the objectives of OOP is to standalone the details of execution from the class definition . It can be therefore a good idea to define the member functions outside the class . You can easliy define a member function outside the class definition yet still allow it to be inline just by making use of the qualifier inline in the header line of the function definition .For eg. class box{............public:void...
Read more

OBJECTS When the class is formed , a number of objects may be created from the class as objects are illustration of the class .Objects are the physical entity to represent classes .A class gives you the blueprints for objects , thus generally an object is formed from a class . We declare objects of a class with precisely the same kind of declaration that we declare variables of fundamental types...
Read more

Concept of classes and objects run side by side.Hence,its beneficial if we discuss the duo together. A class is an extended prospect of a data structure : rather than keeping just data , it may possess both data and functions .An object is an instantiation of a class . When it comes to variables , a class can be the type , as well as an object would be the variable .  Format for declaring a class: class...
Read more

INLINE FUNCTIONS C++ inline function is an effective concept which is commonly used with classes. If a function is inline, the compiler stores a copy of the code of the function at every point exactly where the function is called at compile time.Any kind of change to an inline function might require all clients of the function to be recompiled simply because compiler might need to change all the code once again elsewhere it will continue with old functionality.To inline a function, place the...
Read more

Functions can be called in two ways:- 1)Call by reference 2)Call by value 1)Call by value Call by value is just calling a function simply.Call by value simply copies the values of the arguments in the formal parameters.For eg. #include <iostream.h> int ADD(int m); int main(void) { int n= 50; cout<<"%d %d"<< ADD (n), n); return 0; } int ADD (int n) { n = n + n; return n; } 2)Call by refrence Whenever you declare a variable in a...
Read more

A function is a collection of statements that collectively operate a task. Every single C++ program includes a minimum of one function that is main(), and all the the majority of small programs can define other functions. You may split up your code into different functions. A function name employs the similar rules that have been employed on our variables until now .Further to this,make use of a name that specifies exactly what the function |is predicted to do. FUNCTION DECLARATION In...
Read more

Powered by Blogger.