What does the author mean under the pseudo-code below?

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?

+4
source share
1 answer

B 1): Yes. In my book, I have the following code:

 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) cont { return rep->s[i];} template<class C> String<C>::String<C>() { rep = new Srep(0, C()); } 
+3
source

All Articles