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
please provide me the assignment help. What is the difference between a copy constructor and an overloaded assignment operator?

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

Develop libcurl XML project I have a Project using XML with C++. You will use things like LIbcurl etc....and a XML parser to finish the project. Developer must know how to use X

Discuss the saleint featuresand application of c

Define  F u n c t i o n?  T h e r e a r e t w o t y p e s o f f u n ct i o n b u i l t - i n f un ct i o n s a n d u

in a program for what purpose print f and scan f is used

Imagine that the server program is a setuid program owned by the root, then after you penetrate the program with a shell running, you become the ROOT and you can remove the whole f

Each of the following two procedures defines a method for adding two positive integers in terms of the procedures inc, which increments its argument by 1, and dec, which decrements

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

Ask question #write statement that assign random integer to the varaible n in the (100