1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

C++ エラー備忘録

Posted at

この記事(備忘録) は人に見てもらうことを目的としたものではありません。
あくまでエラーと対処法を後から確認できるようにしたものです。
それとC++は初心者です。

エラー I

./float/network.h: In member function 'void TwoLayerNet::addRelu()':
./float/network.h:16:67: error: invalid new-expression of abstract class type 'ReluLayer'
   16 |             layers.push_back(std::shared_ptr<Layer>(new ReluLayer()));
      |                                                                   ^
In file included from ./float/network.h:4,
                 from ./float/network.cpp:1:
./float/layer.h:44:7: note:   because the following virtual functions are pure within 'ReluLayer':
   44 | class ReluLayer : public Layer{
      |       ^~~~~~~~~
./float/layer.h:9:22: note: 	'virtual void Layer::reset(const Matrix&)'
    9 |         virtual void reset(Matrix const &input)      = 0;
      |                      ^~~~~
make: *** [Makefile:26: network.o] Error 1

解決法

このエラーは仮想関数を他の関数に継承したときに発生した。
厳密にはベクタに追加する作業。
原因は純粋仮想関数を全てのクラスで実装していないことが原因だった。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?