Rabu, 30 November 2016

What are the manipulators in C++

Manipulators are helper functions which can be used for formatting input and output data. The ios class and iomanip.h header file has several pre-defined manipulators.   Below table lists out several pre-defined manipulators. The manipulators hex, oct, dec, ws, endl, and flush are defined in iostream.h. The manipulators setbase(), width(), fill(), etc., that require an argument are defined in iomanip.h. Sometimes, to satisfy custom requirements, we have to create our own manipulator. Such manipulators which are created by the programmer or user are known as user-defined manipulators.   Syntax for creating a user-defined manipulator is as follows:   ostream &

The post What are the manipulators in C++ appeared first on Coding Security.


What are the manipulators in C++
read more

How to implement nested classes in C++

C++ allows programmers to declare one class inside another class. Such classes are called nested classes. When a class B is declared inside class A, class B cannot access the members of class A. But class A can access the members of class B through an object of class B. Following are the properties of a nested class: A nested class is declared inside another class. The scope of inner class is restricted by the outer class. While declaring an object of inner class, the name of the inner class must be preceded by the outer class name and scope

The post How to implement nested classes in C++ appeared first on Coding Security.


How to implement nested classes in C++
read more

How do you allocate memory for an object

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

The post How do you allocate memory for an object appeared first on Coding Security.


How do you allocate memory for an object
read more

Selasa, 29 November 2016

How can we implement nested classes in java

In this article we will look at what is a nested class and how to define a nested class and access the nested class members in a Java program.   Java 1.1 added support for nested classes. A class defined as a member of another class definition is known as a nested class. A nested class can be either static or non-static. The non-static nested class is known as an inner class.   The enclosing class of an inner class can be called as an outer class. An inner class can access all the members of an outer class. But

The post How can we implement nested classes in java appeared first on Coding Security.


How can we implement nested classes in java
read more

what is the use of abstract keyword in java

In this article we will look at abstract keyword in Java. We will learn what is the use of abstract keyword and how to use it in Java programs.   Uses of abstract keyword Following are the uses of abstract keyword in Java: Used to create abstract methods Used to create abstract classes   Creating abstract methods Sometimes while creating hierarchies, a method inside a super class might not be suitable to have any kind of implementation. Such methods can be declared as abstract using the abstract keyword. Syntax for creating an abstract method is as follows: abstract return-type method-name(parameters-list); As candidate example for abstract

The post what is the use of abstract keyword in java appeared first on Coding Security.


what is the use of abstract keyword in java
read more

what are the adapter classes in java

In this article we will learn about adapter classes which are used to simplify the event handling process. Sample Java programs are also provided.   Adapter classes are a set of classes which can be used to simplify the event handling process. As we can see in the mouse event handling program here, even though we want to handle only one or two mouse events, we have to define all other remaining methods available in the listener interface(s). To remove the aforementioned disadvantage, we can use adapter classes and define only the required event handling method(s). Some of the adapter

The post what are the adapter classes in java appeared first on Coding Security.


what are the adapter classes in java
read more

Senin, 28 November 2016

what are bit field classes in c++

A field or member inside a class which allows programmers to save memory are known as bit fields. As we know a integer variable occupies 32 bits (on a 32-bit machine). If we only want to store two values like 0 and 1, only one bit is sufficient. Remaining 31-bits are wasted. In order to reduce such wastage of memory, we can use bit fields. Syntax of a bit field is as follows: type-specifier declarator: width;   In the above syntax declarator is an identifier (bit-field name), type-specifier is the data type of the declarator and width is the size

The post what are bit field classes in c++ appeared first on Coding Security.


what are bit field classes in c++
read more