Multiple constructor, C/C++ Programming

Constructor

public class ListNode< E >

{

   // package access members; List can access these directly

private E data; // data for this node

privateListNode< E >nextNode; // reference to the next node in the list

   // Method Name          : constructor creates a ListNode that refers to object

   // Parameters           : E d

   // Return value(s)      : returns nothing

   // Description          : initializes the parameters and sets nextNode to null

publicListNode( E d )

   {

data = d;

nextNode = null;

   } // end ListNode one-argument constructor

   // Method Name          :  constructor creates ListNode that refers to the specified object and to the next ListNode

   // Parameters           : E d, ListNode< E > node

   // Return value(s)      : returns nothing

   // Description          : initializes the parameters and sets nextNode to null

publicListNode( E d, ListNode< E > node )

   {

data = d;   

nextNode = node; 

   } // end ListNode two-argument constructor

   // Method Name          : method setData

   // Parameters           : E d

   // Return value(s)      : returns nothing

   // Description          : return reference to data in node

public void setData (E d)

   {

data = d;

   }

   // Method Name       : method getData

   // Parameters           : no parameters

   // Return value(s)     : returns data

   // Description           : return reference to data in node

public  EgetData()

   {

return data; // return item in this node

   } // end method getData

   // setNext method

public void setNext(ListNode next)

   {

next = nextNode;

   }

   // return reference to next node in list

publicListNode< E >getNext()

   {

returnnextNode; // get next node

   } // end method getNext

} // end class ListNode< E >

Posted Date: 2/19/2013 1:35:35 AM | Location : United States







Related Discussions:- Multiple constructor, Assignment Help, Ask Question on Multiple constructor, Get Answer, Expert's Help, Multiple constructor Discussions

Write discussion on Multiple constructor
Your posts are moderated
Related Questions
Operation on String - C ++ Program: Write a program to define operations on string in c++. class String {    char *char_ptr;   // pointer to string contents    int le

Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers.

All languages are divided into six sections: - variables, I/O maths, conditional expressions, arrays, functions, subroutines and file handlers. Learning a software language is simi

Define Bitwise-AND Operator: &:? The bitwise-AND operator (&) compares every bit of its first operand to the corresponding bit of its second operand. If both bits are 1 the mat

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

c program for boardcolouring

railway reservation programming

Prepare data from fixed OCR areas scanned. Project Description: Project is to design software which can use character recognition only on certain areas of scanned pdf's/ jpeg

Implementing Operator Functions The general format of the Operator function is: return_type operator op ( argument list );   Where op is the symbol for the operator be

program of area under integration