私は別のオブジェクト内のベクトルにオブジェクトに追加するメソッドを呼び出そうとしています。私はエラーを取得しています。メソッドを呼び出して、クラスへのポインタを渡す
'': Illegal use of this type as an expression
私のプログラムでは、メインにノードを格納するオブジェクトを宣言します。
accountStream *accountStore = new accountStream;
次に、関数を呼び出します。
new_account(&accountStore);
new_account関数は次のとおりです。
void new_account(accountStream &accountStorage)
{
newAccount *account = new newAccount;
(&accountStorage)->pushToStore(account);
}
アカウントストリームクラスにはそれを受け取るベクトルがありますが、どこにエラーがありますか。
class accountStream
{
public:
accountStream();
~accountStream();
template <class account>
void pushToStore(account);
private:
std::vector <newAccount*> accountStore;
};
template<class account>
inline void accountStream::pushToStore(account)
{
accountStore.push_back(account);
}
エラーは最後の2行目です。私はそれは私がメソッドにオブジェクトを渡している方法とは何かだ気持ちを持っているが、しばらくの間、周りいじりの後、私は私がきた場所を正確に突き止めることができていない
accountStore.push_back(account);
間違った。
ありがとうございます! – Dannys19