Showing posts with label DEFINITIONS. Show all posts
Showing posts with label DEFINITIONS. Show all posts

Tuesday, 15 July 2014

What is Memory Allocation ? A Simple Answer.



MEMORY ALLOCATION ( DYNAMIC OR STATIC)


It all starts from a data that is stored in the memory , that data is given some memory .This Process of Giving memory is Called a memory allocation . The memory can be allocated in two manners : DYNAMICALLY AND STATICALLY .

STATIC MEMORY ALLOCATION 

-This memory allocation process reserves fixed mount of memory before actual processing takes place , and because of that , the number of elements to be stored must be predetermined . 
Such memory allocation process is  basically called as static memory allocation .

-The Arrays are allocated memory by this process only.


DYNAMIC MEMORY ALLOCATION

-This Type of memory allocation process gives allocation of memry during the program execution itself, as and when it is needed.This process of allocating memory is called  dynamic memory allocation .
-It also provides technique to release the memory , when memory is not required anymore.

-Data structures like Linked Lists and Tress use this very technique for their memory allocation.

Basics of Linked Lists , Stacks And Queues In C++


Linked Lists , Stacks And Queues


The very basic definitions that a person should know who is learning C++ are :

Linked ListsIT IS A  LINEAR COLLECTION OF DATA ELEMENTS , CALLED AS NODES POINTING TO THE NEXT NODES BY MEANS OF POINTER.

Stacks :  A STACK IS A LINEAR  STRUCTURE IMPLEMENTED IN LIFO (LAST IN FIRST OUT )MANNER WHERE INSERTION AND DELETIONS ARE  RESTRICTED TO OCCUR ONLY AT ONE END - THAT END IS SATCK'S TOP.

Queues: A QUEUE IS  ALSO A LINEAR DYNAMIC STRUCTURE IMPLEMENTED IN FIFO( FIRST IN FIRST OUT) MANNER WHERE INSERTIONS CAN OCCUR AT THE " REAR ' END  , AND THE BASIC DELETIONS OCCUR ONLY AT " FRONT" END.


IMPORTANT POINTS 

LIFO

-Means Element last inserted would be the first one to be deleted.

-The Stack is also  a DYNAMIC DATA STRUCTURE as it can grow( //with increase in number of elements //) or it can shrink(//with decrease in number of elements //).

FIFO:

-Means elements are deleted  in the same order as they are inserted into the queue.

Tuesday, 1 July 2014

Significance of access specifiers in a class in C++.



Significance of access specifiers in  a class


In C++ a class provides three access labels namely , private, protected and public.

A member declared as private or protected in C++ remains hidden from world and it can only be accessed by the member functions of the class itself. 

A member declared as public in C++ program is made available to the outside world. Basically it can accessed by any member functions of the class , by nay expression in the program but only by using a object of the same class type.

The labels listed enforces the data hiding  and abstraction, oop concepts  in C++ 

Basic Concept of Function Overloading With Example


Concept of Function Overloading With Example


The very basic definition of function overloading in C++ is a function name having several definition that are differentiable by the number or the types of their arguments , is known as function overloading.


For Example 

The following example in which the code overloads a function area to find the values of area of circle ,rectangle and triangle.


float area(float r)
{
return 3.1*r*r;
}
float area (float len,float bre)
{
return len*bre;
}
float area(float side1, float side2, float side3)
{
float & = (side1+side2+side3)/2;
float ar = sqrt(&*(&_side1)*(&*(&_side2)*(&*(&_side3));
return ar;
}

Friday, 27 June 2014

Basic Definition of Polymorphism in C++ with example.




Definition of Polymorphism in C++ with example.



The basic definition of polymorphism in C++ is 

Polymorphism is the property by which the message can be sent to objects of several different classes , and each can respond to it in a different way depending upon its class. In C++ Polymorphism is itemplemend through the basic concept called as overloading.



Example  of polymorphism


float a ( float b)
{
return b*b;
}
float a ( float b, float c)
{
return b*c;
}

Thursday, 26 June 2014

What are objects implemented in the C++.



 Objects implemented in the C++.



The basic details like the object implemented in C++ as in terms of the software are



1. Characteristics/attributes are implemented through member variables or from the data items of the object.

2. Behaviour is also implemented through member functions called methods.

3. It is always given a unique name to give its identification.

How can a Class enforce data- hiding, abstraction and encapsulation..

Class enforces data- hiding, abstraction and encapsulation..


What does a class actually do, it binds together data and its associated functions under one unit and because of that enforcing encapsulation as encapsulation means wrapping up of the data and associated functions together into a single unit .

And a Class groups its members into three sections : as private , protected and public.The members like private and protected remains hidden from the outside world.Thus through these private and protected members a  class enforces data hiding.

The Main function of the public member is only to give the important and essential information to the outside world and because of that rest things remain hidden , which is also called as abstraction. As it basically means representation of essentials features without including the background details .

Abstraction and Encapsulation in C++

Abstraction and Encapsulation in C++



Basically in C++ the shortest definition of these two can be is 


Abstraction

 Is the act of basically representing essential features without including the background details.

And


The Encapsulation

Is the way of combining both data and the functions that operate on the data under a single unit .

Encapsulation is the way of implementing abstraction.

Wednesday, 25 June 2014

Local Variables and Global Variables in C++


Local Variables and Global Variables



The Basic Difference Between the Local Variables and Global Variables is


Local Variables

1.  It is basically a variable which is declared with in a function or inside the block.

2. It is basically accessible only within a function or within a block in which it is declared .


Global Variables

1. It is basically a variable declared outside all the functions.

2. It is accessible throughout the program .


EXAMPLE :

Tuesday, 24 June 2014

What is the difference between Type Casting and Automatic Type Conversion in C++...with Examples.

Difference Between Type Casting and Automatic Type Conversion ...with Examples.



Automatic Type Conversion

IN C++  an automatic type casting  or implicit type conversion is a type of data type conversion which is  performed by the compiler on its own. It basically occurs whenever an expression has different data type .In this type of conversion , the data type which are smaller are converted into larger data type to avoid data loss.  

Example:

int x=3,y=1,c;
float p=11.5,q;
q=p/x;

In the above case the expression p/x, x's type will automatically be promoted to bigger type float  and then the expression will be evaluated .

TYPE CASTING 

The type casting or explicit type conversion  is user - defined forced conversion . It is basically done with the help of operator ( ) called as casting operator . 

Example:

float p=(float) 22/7;

Explanation 

Then 22 will be first converted to float type and this expression will get  evaluated.

What are Run time and Syntax Error in C++ with Examples.


What are run time and syntax error in C++ with examples.




In C++ the runtime error is an error that occurs basically at the time of execution of a program . The compilation of the program is not affected with it .

Example for this is :

"File could not be opened ","Not enough memory available " , are run time errors.





A syntax error is that when statements are wrongly written violating rules and regulations of the C++ programming language .

For example :

MAX+2=DMAX is an syntax error as an expression can not appear on the left side of an assignment operator.

What is a reference variable and it's usage ?




A Reference Variable and it's Usage.


 DEFINITION


In C++ the reference variable is an alias  name given  for an previously defined variable.

USAGE 
 
The usage of it is that the same data object can be referred to by two names and these names can be used interchangeably.

What are data type modifiers and their affect on base data type.





Data type modifiers and their affect on base data type.




The keyword which appear before the data type and which changes its meaning , are modifiers.These are signed , unsigned , short, and long . When data type modifiers appears before a type , the meaning of the data type changes in the sense that the size gets affected.

For the sake of example let's see

An int is by default 2 bytes long and hence can represent values -32768 to 32767 but when modifier unsigned appears before it , its range becomes 0 to 65,535.

Monday, 23 June 2014

Is Char often treated as integer data type .



 Char often treated as integer data type

Basically it deals with the memory implementation of char data type is in terms of the terms of the number code (which is integer).
Therefore Because of this  , it is said to be another integer data type .

Sunday, 22 June 2014

What are data types in c++ and predefined data types in C++ ?

 


Data types in c++ and Predefined data types in C++

 
The Data types are the means to identify the type of data entered and associated operations of handling it.
 
In the C++ there are two  types of data types :
 
1. Fundamental data types These are the data types that are not composed of any other data type . There are five fundamental data types : char, int ,float, double, and void.
 
2. Derived data types These are the data types that are composed of fundamental data types . These are : array , function, pointer,reference , constant , class , structure,union, and enumertion.



What are 'a' and ''a'' in c++ . Difference Between single quotes and double quotes.

 
 
Single quotes and Double quotes 'a' and ''a'' in C++


 

What is basic difference between the single quotes ('a') and the double (''a") , that we usually use in c++ and gets confused between these two.

So the characters which are enclosed in the single qoutes are character constants in C++.Thus 'a' is a character constant.The chraracter enclosed in double quotes sre basiclly string literals which are array of characters.Thus "a" is a string and size of the 'a' is 1 character   whereas the size of the "a" is 2 characters.


Saturday, 21 June 2014

What are Character sets and Tokens in c++ ?




CHARACTER SETS AND TOKENS


Definition Of character set

A character set is a set of valid characters that a language can recognise . A character set represent any letter , digit , or any other sign . C++ has the following set:

Letters    :  A-Z , a-z

Digits :       0-9

Special Symbols :  Space   + - * / ^ \ () [] {} =  > <  . ' " $ , ; : ......etc.

White Spaces:  Blank space , Horizontal tab (->)Carriage return , new line , Form feed.

Other Characters :  C++ can process any of the 256  ASCII  characters.



TOKENS

Tuesday, 17 June 2014

What is c++ programming language ?




C++ PROGRAMMING LANGUAGE 


THE DEFINITION AND WHAT IS C++ LANGUAGE:

The programming Language C++ was developed at At&T Bell Laboratories in the early's 1980 by Bjarne Stroustrup.Basically He found the 'C' for lacking of simulations and decided to extend the language by adding more features from his favourite languag 'simula 67'  .The earliest object oriented languages was the simula 67 .