: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.

Recommended Answers

All 5 Replies

Okay, what do you have so far?

This is the question!

The only way to learn and master c++ is if you practice and get corrected....

With all the pace of continental drift, your reply to "urgent" took all of 2 YEARS.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.