the temp and exception about C++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gabrielpondc
    New Member
    • Nov 2018
    • 1

    the temp and exception about C++

    Please give me detail,thx I'm sorry about ask my assignment but I'm already done this assignment at last week but I'm just get 1 Grade at the first question cause I'm foreign student so actually I'm asked my professor but i still can't understand when professor description for me so i seek help and give alot detail at this assignment Thanks

    Write template functions MAX and MIN that output maximum/min values from a given data array. Make sure the following main () functions operate normally (y and a).
    int main(){

    char buf[] = "partytime" ;

    cout << MAX<char>(buf, 9) << endl;

    cout << MIN<char>(buf, 9) << endl;

    }

    Create an array class that covers the array of given data types. Make sure the following main () functions operate normally (302010 output).
    int main(){

    Array<int> a;

    a.push(10); a.push(20); a.push(30);

    cout << a.pop() << a.pop() << a.pop();
    }

    Describe the output of the following program.
    #include <iostream>

    using namespace std;

    template <typename T, T* LIST, int SIZE, T (*FUNC)(T)>

    struct Composed {

    T sum(){

    T result = 0;

    for(int i = 0; i<SIZE; ++i){

    result += FUNC(LIST[i]);

    }

    return result;

    }

    };

    int array[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

    int square(int i){ return i*i; }

    int main()

    {

    Composed<int, array, 10, square> c;

    cout << c.sum() << endl;

    }
Working...