0

:sad: Write a C++ template class Nvector that enables arrays with negative subscripts to be
defined. The class should be usable in the following code fragment:

Nvector<double> a; // instantiate double array class
a.resize(-10, 10); // allocate array from locations -10 to 10
for(int i=-10 ; i<=10 ; ++i)
a[i] = exp(-k*(T-t[i])); // fill array

<< moderator edit: added code tags: [code][/code] >>

The class should be written so that array set/access is optimally efficient. Show through the template specification that multidimensional arrays can also be defined.

5
Contributors
5
Replies
6
Views
12 Years
Discussion Span
Last Post by Salem
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.