questions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nono909
    New Member
    • Oct 2006
    • 4

    #1

    questions

    i need answers for the following questions so i'll be prepaed for my next exam.please

    Q1. Write the copy constructor for a dynamic array class template.
    is the following answer right?
    template <class T>
    DynamicClass<T> :: DynamicClass(co nst DynamicClass<T> & obj)

    Q2. Write the addItemToHead and AddItemToTail functions for a linked list. Assume the rest of the linkedList class is complete.
    Q3. ) Here is a program with an array of size 100. Change the code to allow the user to size the array at run-time. Add all code necessary. Write your additions to the right, cross out any unneeded code.
    int getData();//A totally made up function, implementation not needed.
    int main()
    {
    int i, array[100];

    for(i=0;i<100;i ++)
    {
    array[i] = getData();
    }

    for(i=0;i<100;i ++)
    {
    if(array[i] % 2 == 0) //even num
    {
    cout << array[i] << endl;
    }
    }
    return 0;
    }

    Q4. Write a sequential search function template for an array.
    Q5. Implement the addItemInOrder function for a linked list. Assume that the list has a head and a tail, and the the node class has int data, and a next pointer.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by nono909
    i need answers for the following questions so i'll be prepaed for my next exam.please

    Q1. Write the copy constructor for a dynamic array class template.
    is the following answer right?
    template <class T>
    DynamicClass<T> :: DynamicClass(co nst DynamicClass<T> & obj)

    Q2. Write the addItemToHead and AddItemToTail functions for a linked list. Assume the rest of the linkedList class is complete.
    Q3. ) Here is a program with an array of size 100. Change the code to allow the user to size the array at run-time. Add all code necessary. Write your additions to the right, cross out any unneeded code.
    int getData();//A totally made up function, implementation not needed.
    int main()
    {
    int i, array[100];

    for(i=0;i<100;i ++)
    {
    array[i] = getData();
    }

    for(i=0;i<100;i ++)
    {
    if(array[i] % 2 == 0) //even num
    {
    cout << array[i] << endl;
    }
    }
    return 0;
    }

    Q4. Write a sequential search function template for an array.
    Q5. Implement the addItemInOrder function for a linked list. Assume that the list has a head and a tail, and the the node class has int data, and a next pointer.
    You need to read the tutorials and post only when you are really stuck please.

    Comment

    Working...