Constructors and Destructors in JAVA

Before we learn about the Constructor and destructor let us discuss how to create an object in JAVA programming language. Creation of an object in JAVA:- We cannot create an object in java like C and C++ syntax like, demo d; In C++, we can read this statement as d is an object of a demo class. But in java this statement is considered as d is a reference which can refer to an object of type demo class. Means in java, a memory for that d is only for that reference. To…Read more

Software Testing Fundamentals

Software testing method for testing software This article is related to software testing in this article the fundamentals relate to testing are described. This articles present ideas of testing in simple language for those who are interested in career of software testing. For every software project we see, there is an inherent conflict of interest that occurs as testing begins. The people who have built the software are now asked to test the software.  The main idea of testing is vested interest in demonstrating that the program is free of errors i.e. free…Read more

Namespace and Templates in C++

Namespace:- There is a team development in C++ for creating a single application. Due to this team development different team members may use a same identifier for the function or any data types. Due to this same name compiler generates ambiguity error. To remove this error we have to use the concept ‘namespace’. ‘namespace’ is a work area or a declarative region that attaches an additional identifier to any names declared inside that appropriate namespace. In C++, there is default namespace as std and we are going to provide user defined namespaces under…Read more

Dynamic memory allocation in C++

Dynamic memory allocation:- In C, we can allocate dynamic memory by using malloc, calloc ande realloc library functions. All the above functions are applicable in C++. But there are some disadvantages in C++. To avoid those disadvantages C++ provides its own memory allocation and de-allocation mechanism For dynamic memory allocation in C++ we have to use ‘new’ operator and to de-allocate that memory we have to use ‘delete’ operator. When we allocate a memory by using ‘new’ then we can not de-allocate a memory by using free(). ‘new’ operator internally calls malloc and…Read more

Virtual Destructors and function chaining in C++

Virtual Destructor:- As like a normal function we can create a destructor as virtual. If the class contains at least a single virtual destructor then VPTR is created and it is initialized with appropriate v-table. Virtual destructors are necessary if there is an inheritance and up casting concept is used. If virtual destructors are not written then there is a chance of a memory leak. e.g. class base { public: base() { cout<<”base class constructor.”; } ~base() { cout<<”base class destructor.”; } }; class derived:public base { derived() { cout<<”derived class constructor.”; }…Read more

Operator overloading in C++

Operator overloading:- Operator overloading is a syntactic sugar. It is the type of compile time polymorphism. Overloaded operators are used for class objects or other data members other than basic data types. When we overload an operator we do not have to call explicitly that overloaded function. It is a rule that, 1)    Do not change the meaning of previously defined operator (but we can change the meaning). 2)    Do not change precedence and associatively of that operator. We can provide an overloaded function of an operator as a member function or a…Read more

Friend Concept and ‘mutable’ Keyword in C++

Friend:- By using a friend concept we can access a private member of a class. There are multiple types of a members can be friend of our class. 1)    A friend can be any member function of a class. 2)    A friend can be any function which is not a part of any class. 3)    Whole class can be a friend of our class. Before using friend we have to use a forward declaration means we have to declare friend class at the start of a program. class friend_class; void fun(friend_class *fp) {…Read more

Inheritance in C++

Composition:- A Composition is similar as an inheritance. A Composition means writing an object of some another class inside some another class. This gives a same effect as an inheritance but there are some functional differences in an inheritance and a composition. e.g. class demo { public: int i; void fun() { cout<<”inside the fun of a demo class.” } }; class hello { public: int x; demo d; void gun() { cout<<”inside the gun of a hello class.”; } }; int main() { demo d1; hello d2;;; return 0; }…Read more

File I/O Solution in C

This is a full  file I/O  solution where user enters some information on the terminal and this user input is then stored into the file. Also this is a structured file operation program which supports : 1) Insertion of a record 2) Deletion of a record 3) Updation of a record 4) Searching of a record Note: This program assumes that user enters the data in the correct specified format and order as required for further processing. i.e. Where the input is number and user enters a character , the program will go…Read more

Local, Nested Class and ‘this’ pointer in C++

Local Class:-   • If a class is defined inside any function then that class is called as local class. • This local class is used only inside a particular function. • We can not create an object of this local class outside that function. • According to above point local class works same as a local variable inside a function. e.g. class hello { void fun() { class demo { public: int i; }; demo d; d.i=10; } // function ends. }; • In an above example, demo class is considered as…Read more