私はこのようなクラスがあります。Foo
のm_value
がプライベートである(と私は維持したいと思いますのでフレンド機能
template<class X, class Y>
class Blarg : public Bar {
// ...
void SetValue(double _val) { Foo::m_value = _val; }
// ...
};
:
#include "Blarg.h"
// ...
class Foo : public Bar {
// ...
static double m_value;
// ...
};
そして、このような別のものをそのように)、私はFoo
クラスの友人としてSetValue
関数を宣言して、必要なときに静的メンバーにアクセスできると考えました。
template<class X, class Y> friend void Blarg<X, Y>::SetValue(double _val);
template<class X, class Y> friend void Blarg::SetValue(double _val);
friend void Blarg::SetValue(double _val);
を...しかし、コンパイルするには運:
私はFoo
の公共エリア内のこれらの線に沿っての宣言を試していないしました。可能であれば、これに対する正しい構文は何ですか?
最初のエラーではどのようなエラーが発生しますか? – Praetorian
「コンパイル中の不運」は、直面したエラーの技術的な説明ではありません。 –
各クラス定義の後に ';'を書く必要があります。 –