Month: June 2014

OOP in C++

Posted on

For the students of FYBSc (IT), SYBSc (CS), SYBCA

THE COPY CONSTRUCTOR

The copy constructor is a constructor which creates an object by initializing it with an object of the same class, which has been created previously. The copy constructor is used to:

  • Initialize one object from another of the same type.
  • Copy an object to pass it as an argument to a function.
  • Copy an object to return it from a function.

If a copy constructor is not defined in a class, the compiler itself defines one. If the class has pointer variables and has some dynamic memory allocations, then it is a must to have a copy constructor. The most common form of copy constructor is shown here:

classname (const classname &obj){   // body of constructor}

Here, obj is a reference to an object that is being used to initialize another object.

#include<iostream>

classLine

{

public:

int getLength(void);

Line(int len );             // simple constructor

Line(constLine&obj);  // copy constructor

~Line();                     // destructor

private:

int*ptr;

};

// Member functions definitions including constructor

Line::Line(int len)

{

cout <<“Normal constructor allocating ptr”<< endl;

// allocate memory for the pointer;

ptr =newint;

*ptr = len;

}

Line::Line(constLine&obj)

{

cout <<“Copy constructor allocating ptr.”<< endl;

ptr =newint;

*ptr =*obj.ptr;// copy the value

}

Line::~Line(void)

{

cout <<“Freeing memory!”<< endl;

delete ptr;

}

intLine::getLength(void)

{

return*ptr;

}

void display(Line obj)

{

cout <<“Length of line : “<< obj.getLength()<<endl;

}

// Main function for the program

void main()

{   Line line(10);

display(line);}

When the above code is compiled and executed, it produces the following result:

Normal constructor allocating ptr

Copy constructor allocating ptr.

Length of line : 10

Freeing memory!

Freeing memory!

 

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

Advertisements

Functional Dependency

Posted on Updated on

USEFULL FOR FYBSC (IT) & TYBSC (CS) STUDENTS

 

·         In the process of efficiently storing data, and eliminating redundancy, tables in a database are designed and created to be in one of five possible normal forms.  Each normal form contains and enforces the rules of the previous form, and, in turn, applies some stricter rules on the design of tables.·         A set of tables in a database are initially said to be in 0 normal form. First Normal Form:

  • Tables are said to be in first normal form when:-
  • The table has a primary key.-
  • No single attribute (column) has multiple values.-
  • The non-key attributes (columns) depend on the primary key.
  • Some examples of placing a table in first normal form are:

2

In first normal form the table : –

4

 

Second Normal Form:

  • Tables are said to be in second normal form when:
  • o   The tables meet the criteria for first normal form.
  • If the primary key is a composite of attributes (contains multiple columns), the non key attributes (columns) must depend on the whole key.
  • Third Normal Form:
  •  Tables are said to be in third normal form when:
  • o   The tables meet the criteria for second normal form.
  • o   Each non-key attribute in a row does not depend on the entry in another key column. Fourth
  • Normal Form:
  • Tables are said to be in fourth normal form when:
  • o  The table meets the criteria for third normal form.
  •  Situations where non-key attributes depend on the key column exclusive of other non-key columns are eliminated. Fifth Normal
  • Form:
  • Tables are said to be in fifth normal form when:
  • o The table meets the criteria for fourth normal form.
  • o The table consists of a key attribute and a non-key attribute only.

 

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

 

OOP in C++

Posted on

For the students of FYBSc (IT), SYBSc (CS), SYBCA

C++ Identifiers:

  • A C++ identifier is a name used to identify a variable, function, class, module, or any other user-defined item. An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores, and digits (0 to 9).
  • C++  does  not  allow  punctuation  characters  such  as  @,  $,  and  %  within  identifiers.
  • C++ is a case-sensitive programming language. Thus, Manpower and manpower are two different identifiers in C++.

 

  • Here are some examples of acceptable identifiers:

Name1                        abc                  move_name                    a_123

Myname_50                num1              num2                           temp retVal

 

C++ Keywords:

  • The following list shows the reserved words in C++.  These reserved words may not be used as constant or variable or any other identifier names.

else      new    this  Auto         enum             operator          throw             Bool    explicit

private             true    Break              export   protected   try  Case   extern   public   typedef

Catch   false   register   typeid  Char   float   reinterpret_cast    typename

Class  for  return  union Const  friend  short         unsigned const_cast   goto  signed  using

continue  If      sizeof             virtual             Default  inline  Static  void Delete  int  static_cast              volatile

Do  long          Struct              Double            mutable                      Switch                          while  dynamic_cast  namespace  Template

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

 

 

 

Functional Dependency

Posted on

USEFULL FOR FYBSC (IT) & TYBSC (CS) STUDENTS

Functional Dependency

Functional dependency (FD) is set of constraints between two attributes in a relation. Functional dependency says that if two tuples have same values for attributes A1, A2,…, An then those two tuples must have to have same values for attributes B1, B2, …, Bn.

Functional dependency is represented by arrow sign (→) that is X→Y, where X functionally determines Y. The left hand side attributes determines the values of attributes at right hand side.

Armstrong’s Axioms

If F is set of functional dependencies then the closure of F, denoted as F+, is the set of all functional dependencies logically implied by F. Armstrong’s Axioms are set of rules, when applied repeatedly generates closure of functional dependencies.

  • Reflexive rule: If alpha is a set of attributes and beta is_subset_of alpha, then alpha holds beta.
  • Augmentation rule: if a → b holds and y is attribute set, then ay → by also holds. That is adding attributes in dependencies, does not change the basic dependencies.
  • Transitivity rule: Same as transitive rule in algebra, if a → b holds and b → c holds then a → c also hold. a → b is called as a functionally determines b.

Trivial Functional Dependency

  • Trivial: If an FD X → Y holds where Y subset of X, then it is called a trivial FD. Trivial FDs are always hold.
  • Non-trivial: If an FD X → Y holds where Y is not subset of X, then it is called non-trivial FD.
  • Completely non-trivial: If an FD X → Y holds where x intersect Y = Φ, is said to be completely non-trivial FD.

Normalization

If a database design is not perfect it may contain anomalies, which are like a bad dream for database itself. Managing a database with anomalies is next to impossible.

  • Update anomalies: if data items are scattered and are not linked to each other properly, then there may be instances when we try to update one data item that has copies of it scattered at several places, few instances of it get updated properly while few are left with there old values. This leaves database in an inconsistent state.
  • Deletion anomalies: we tried to delete a record, but parts of it left undeleted because of unawareness, the data is also saved somewhere else.
  • Insert anomalies: we tried to insert data in a record that does not exist at all.

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

 

Trees in Data structures

Posted on

USEFUL FOR FYBSC (IT), FYBCA STUDENTS  

 

Trees

 Binary Trees

The simplest form of tree is a binary tree. A binary tree consists of

  1. a node (called the root node) and
  2. left and right sub-trees.
    Both the sub-trees are themselves binary trees.

03

A binary tree

The nodes at the lowest levels of the tree (the ones with no sub-trees) are called leaves.

In an ordered binary tree,

  1. the keys of all the nodes in the left sub-tree are less than that of the root,
  2. the keys of all the nodes in the right sub-tree are greater than that of the root,
  3. the left and right sub-trees are themselves ordered binary trees.

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

OOP in C++

Posted on

OBJECT ORIENTED PROGRAMMING

 

  • OOPstands for Object Oriented Programming. This is a technique used to develop programs revolving around the real world entities. In OOPs programming model, programs are developed around data rather than actions and logics.
  • In OOPs, every real life object has properties and behavior, which is achieved through the class and object creation. They contain properties (variables of some type) and behavior (methods). OOPs provide a better flexibility and compatibility for developing large applications.
  • Reusability of Code:  In object oriented programming one class can easily copied to another application if we want to use its functionality .E.g.  When we work with hospital application and railway reservation application .In both application we need person class  so we have to write only one time the person class  and it can easily use in other application.
  • Easily Discover a bug: When we work with procedural programming it take a lot of time to discover a bug and resolve it .But in object   Oriented Programming   due to modularity of classes we can easily discover the bug and we have to change in one class only and this change make in all the application only by changing it one class only.
  • Object- Oriented Programming enables us to easily model our applications based on the real world which help us to easily identify the requirements, what code is to be written and how different classes interact with each other which have same properties and behaviors.

APPLICATIONS OF OOPS

  • OOP has become one of the programming buzz words today. There appears to be a great deal of excitement and interest among software engineers in using OOP.
  • Applications of OOP are beginning to gain importance in many areas. The most popular application of object-oriented programming, up to now, has been in the area of user interface design such as window. Hundreds of windowing systems have been developed, using the OOP techniques. Real-business system are often much more complex and contain many more objects with complicated attributes and method. OOP is useful in these types of application because it can simplify a complex problem. The promising areas of application of OOP include:
  •   Real-time system
  •   Simulation and modeling
  •   Object-oriented data bases
  •   Hypertext, Hypermedia, and expertext
  •   AI and expert systems
  •   Neural networks and parallel programming
  •   Decision support and office automation systems
  •   CIM/CAM/CAD systems

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

 

DATA BASE ARCHITECTURE

Posted on Updated on

USEFULL FOR FYBSC (IT) & TYBSC (CS) STUDENTS

 

DATABASE MODEL

  •  A database model defines the logical design of data. The model describes the relationships between different parts of the data.
  • Basically three models are  –

(i)                Hierarchical model

(ii)              Network model

(iii)            Relational model

  •  Hierarchical model

In his model each entity has only one parent but can have several children. At the top of hierarchy there is only one entity which is called ROOT.

2

  • Network model

In the network model, entities are organized in a graph, in which some entities can be accessed through several paths.

3

  • Relational model

In this model, data is organized in two-dimensional tables called relations. The tables or relation are related to each other.

4

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com