473,387 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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;

}
Nov 21 '18 #1
0 1153

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

Similar topics

4
by: maricel | last post by:
I have the following base table structure - DDL: CREATE TABLE "ADMINISTRATOR"."T1" ( "C1" INTEGER NOT NULL ) IN "TEST_TS" ; ALTER TABLE "ADMINISTRATOR"."T1" ADD PRIMARY KEY
2
by: Steven Jones | last post by:
Im just learning C an do not understand why the following code fails. The while loop apperas to work fine until it bombs out with a floating point exception. Whats going on? Thanks /* *...
1
by: Phil Short via DotNetMonster.com | last post by:
I'm having trouble using a temp table in Oracle. Here's my code: Dim myConn As OleDbConnection Dim strconn As String = Session.Item("optSrcDBConnect") Dim dcSQL As OleDbCommand Dim strSQL As...
1
by: guzmanp | last post by:
I have this error message: Please anyone knows how I resolve this? An unexpected exception has been detected in native code outside the VM. Unexpected Signal : EXCEPTION_ACCESS_VIOLATION...
3
by: Nindi73 | last post by:
Hi, I am in need of a deep copy smart pointer (Boost doesn't provide one) which doesnt require the contained types to have a virtual copy constructor. I wrote a smart pointer class that I think...
9
by: Frawls | last post by:
Hi I Am am having problems with a stored Procedure that i wrote. Basically whats happening is that the Stored procedure Runs fine when i EXECUTE it in SQL Query analyzer. But when i debug...
1
by: kreator | last post by:
Hi i got an Access Violation error with AnsiStrings n char*. First chance exception at $7C812A5B. Exception class EAccessViolation with message 'Access violation at address 0040467E in module...
16
by: George2 | last post by:
Hello everyone, The following swap technique is used to make assignment operator exception safe (means even if there is exception, the current object instance's state is invariant). It used a...
1
by: differentsri | last post by:
THIS IS AN ASP.NET 1.1 APPLICATION IAM TRYING TO UPDATE THE FIELD BUT I AM NOT ABLE TO UPDATE IT? CAN U TELL THE REASON ? IT IS GIVING THE FOLLOWING ERROR BELOW I HAVE ALSO GIVEN THE CODE OF...
3
by: Robert Rawlins | last post by:
Hi Mk, Yeah it's got me a little bemused to be honest, I've tried playing around with configuration options this morning and not been able to achieve anything that works properly. I'll keep...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.