Senin, 03 Oktober 2016

what are the Advantages and Disadvantages of Inheritance

Advantages of inheritance are as follows: Inheritance promotes reusability. When a class inherits or derives another class, it can access all the functionality of inherited class. Reusability enhanced reliability. The base class code will be already tested and debugged. As the existing code is reused, it leads to less development and maintenance costs. Inheritance makes the sub classes follow a standard interface. Inheritance helps to reduce code redundancy and supports code extensibility. Inheritance facilitates creation of class libraries.   Disadvantages of inheritance are as follows: Inherited functions work slower than normal function as there is indirection. Improper use of inheritance

The post what are the Advantages and Disadvantages of Inheritance appeared first on Coding Security.


what are the Advantages and Disadvantages of Inheritance
read more

Minggu, 02 Oktober 2016

How to allocate memory for objects and classes

Class is not allocated any memory. This is partially true. The functions in a class are allocated memory which are shared by all the objects of a class. Only the data in a class is allocated memory when an object is created. Every object has its own memory for data (variables). For example consider the following Student class and its functions: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 class Student { private: string name; string regdno; string branch; int

The post How to allocate memory for objects and classes appeared first on Coding Security.


How to allocate memory for objects and classes
read more

what is the difference between local and nested class

Local Classes   A class which is declared inside a function is called a local class. A local class is accessible only within the function it is declared. Following guidelines should be followed while using local classes: Local classes can access global variables only along with scope resolution operator. Local classes can access static variables declared inside a function. Local classes cannot access auto variables declared inside a function. Local classes cannot have static variables. Member functions must be defined inside the class. Private members of the class cannot be accessed by the enclosing function if it is not declared

The post what is the difference between local and nested class appeared first on Coding Security.


what is the difference between local and nested class
read more

what are volatile objects and member functions

Volatile Objects and Member Functions   An object which can be modified by some unknown forces (like hardware) other than the program itself can be declared as volatile. Compiler doesn’t apply any optimizations for such volatile objects. Syntax for declaring an volatile object is as follows: volatile ClassName object-name;   A member function can be declared as volatile to make the access to member variables to be volatile. A volatile object can access only volatile functions. Syntax for creating a volatile function is as follows: return-type function-name(params-list) volatile;   Following program demonstrates both volatile objects and volatile programs: 1 2 3 4 5

The post what are volatile objects and member functions appeared first on Coding Security.


what are volatile objects and member functions
read more

Sabtu, 01 Oktober 2016

what is formatted and unformatted data in C++

Formatted and Unformatted Data   Data which is received by the program without any modifications and sent to the output device without any modifications is known as unformatted data. On the other hand, sometimes we may want to apply some modifications to the actual data that is being received or sent. For example, we might want to display an integer in hexadecimal format in the output, leave some whitespace when printing a number and adjustments in the decimal point. Such modified data in known as formatted data.   As an example for formatted data, if we want to display a

The post what is formatted and unformatted data in C++ appeared first on Coding Security.


what is formatted and unformatted data in C++
read more

What are stream classes in C++

Streams in C++   In C++, standard library maintains input and output as streams. A stream is a flow of data, measured in bytes, in sequence. If data is received from input devices, it is called a source stream and if the data is to be sent to output devices, it is called a destination stream.   The data in the source stream can be used as input to the program. Then it is called an input stream. The destination stream can be used by the program to send data to the output devices. Then it is called an output

The post What are stream classes in C++ appeared first on Coding Security.


What are stream classes in C++
read more

what are types of constructors in C++

Types of Constructors   A constructor can be classified into following types: Dummy constructor Default constructor Parameterized constructor Copy constructor Dynamic constructor   Dummy Constructor   When no constructors are declared explicitly in a C++ program, a dummy constructor is invoked which does nothing. So, data members of a class are not initialized and contains garbage values. Following program demonstrates a dummy constructor: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 #include <iostream> using namespace std; class Student { private: string name;

The post what are types of constructors in C++ appeared first on Coding Security.


what are types of constructors in C++
read more