在330頁從B.Stroustrup的獲得以下的「C++程序設計語言」第三版:作者用下面的僞代碼表示什麼?
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());
}
我對上面的構造函數的兩個問題:
1)不宜p
替代通過rep
?
2)ctor Srep(0, C())
應該如何在商店中構造一個Srep
對象?
可能是一個錯字:) – 2013-02-24 18:55:00
已經有20+打印,在我的版本p是代表。 – 2013-02-24 18:55:12
@Red Serpent但是構造函數調用'Srep(0,C())'呢? – WaldB 2013-02-24 18:56:11