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
Should I call a destructor explicitly on a local variable?

Implementation of the Stack class in C++: How to implement stack class in c++. int Stack::push(int elem) {    if (top    {       list[top++] = elem;       r


Define Polymorphism? A: Polymorphism let a client to treat distinct objects in the similar way even if they were developed from distinct classes and exhibit different behaviors.

It is a feature in C++ to reduce name collisions in the global name space. This namespace keyword assigns a separate name to a library that allows other libraries to use the simila

Project Description: I need to convert AFL code of Amibroker to DLL plugin to hide original formula, and also to protect the DLL and making it hardware locked. I need to wrap th

There is a pebble merchant. He sells the pebbles, that are used for shining the floor. His main duty is to take the length of the room’s sides. But he sometimes mistakes doing that

Determine the size of an interger data type without using sizeof() function? A: #include int main() { int *i ; int *j = i + 1; cout }


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