クラステンプレートを考える:リターンクラスREF
template <typename T>
class my_class
{
public:
my_class& test1() { return *this; }
// OR
my_class<T>& test2() { return *this; }
}
をtest1
とtest2
の戻り値の型との間の違いはありますか?
クラステンプレートを考える:リターンクラスREF
template <typename T>
class my_class
{
public:
my_class& test1() { return *this; }
// OR
my_class<T>& test2() { return *this; }
}
をtest1
とtest2
の戻り値の型との間の違いはありますか?
戻り値の型が
test1
とtest2
の間に違いはありますか?
いいえ。injected-class-nameという概念があります。 my_class<T>
の本文内では、my_class
という名前はフルタイプmy_class<T>
を指します。
私たちも、その論理的結論にこれを取ると追加することができます。
my_class::my_class::my_class::my_class& test4() { return *this; }
いいえ、範囲内my_class<T>
、my_class
は、my_class<T>
の略語です。
いや、もっと 'my_class'ニーズ – wasthishelpful
号(ジャガイモ)はありません。 –