423,851 Members | 2,762 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,851 IT Pros & Developers. It's quick & easy.

the temp and exception about C++

P: 1
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;

}
3 Weeks Ago #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.