The following was obtained on page 330 of B. Stroustrup "C ++ Programming Language" Third Edition:
template<class C> struct String<C>::Srep { C* s; // pointer to elements int sz; // number of elements int n; // reference count // ... }; template<class C> C String<C>::read(int i) const { return rep->s[i];} template<class C> String<C>::String() { p = new Srep(0, C()); }
I have two questions about the above constructor:
1) Should not replace p with rep ?
2) How should ctor Srep(0, C()) build a Srep object in the repository?
Waldb source share