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
Memory management by c program: Write a program to memory management in c program unsigned max( unsigned, unsigned );   int BaseMemBlocks::allocBlock( size_t sz )


write a program to calculate the cuboid

I want VLC Pitch Changing Addon Project Description: Required: Plugin to modify the pitch of running tracks in VLC without changing the speed. Skills required are C Progra

I have a Matlab assignment and I have the assignment description+ algorithm + and the output sample. the files are on a dropbox folder and you can download them from the link below

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

decodes the sending smuggler string from the number format into plain text

how to convert a general tree into binary tree with example

should i put define constant and memory constant in my flowchart? the other one, how to draw flowchart for break and continue statement?

The concept of a string in C is difficult, because a string is a collection of characters stored in memory terminated by a NULL string i.e. \0. Let us consider the string Hello. Th