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
Write a function that calculates the number of elapsed days between two dates. For example the days between Feb 3, 1970 and June 21, 1980? Becareful for the Leap year.

Write a program to calculate the timetable for numbers 1 -> 10 and display them as follows. Your solution should use for do loops      #include stdio.h void main() {    char p

want the codings for these topic in ur experts minds.com


Introduction to Classes Object-oriented programming (OOP) is a conceptual approach to design programs. It can be executed in many languages, whether they directly support OOP c

Selecting Array Elements Implement the following C++ code in assembly language, using the block-structured .IF and .WHILE directives. Assume that all variables are 32-bit signed in

(a) client server or multithreaded client-server, where server will create pool of worker threads (say 5) to provide services to pool of clients (say 5 ).Server should be behaving

#include int main() { int T; int N; int i; scanf("%d",&T)

Explain the Macros? Preprocessor' is a translation stage that is applied to your source code before the compiler proper gets its hands on it. Usually the preprocessor performs

the program that solve the efficiency of otto cycle