here - Chara - University of Illinois at Urbana-Champaign
here - Chara - University of Illinois at Urbana-Champaign
here - Chara - University of Illinois at Urbana-Champaign
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Lecture<br />
04—Templ<strong>at</strong>e<br />
P<strong>at</strong>terns I<br />
Chase Geigle<br />
Announcements<br />
Templ<strong>at</strong>e<br />
Specializ<strong>at</strong>ion<br />
Partial<br />
Templ<strong>at</strong>e<br />
Specializ<strong>at</strong>ion<br />
Templ<strong>at</strong>e<br />
Templ<strong>at</strong>e<br />
Parameters<br />
Next Time<br />
Modified Implement<strong>at</strong>ion (Cont’d.)<br />
templ<strong>at</strong>e <br />
class vector {<br />
public:<br />
~vector() {<br />
for( size_t i = 0; i < size_; ++i )<br />
delete ptr;<br />
delete [] d<strong>at</strong>a_;<br />
}<br />
// other things<br />
priv<strong>at</strong>e:<br />
T ** d<strong>at</strong>a_;<br />
};<br />
Note th<strong>at</strong> T still refers to int in an instanti<strong>at</strong>ion <strong>of</strong><br />
vector, so we need the T ** declar<strong>at</strong>ion <strong>of</strong><br />
d<strong>at</strong>a .