-2
C++でのプログラミングを始めたばかりで、「変数型 'Rectは抽象クラスです」という理由が分かりません。 私のコードの一部はここにあります: C++のクラスからオブジェクトを作成する
main(){
Rect r1(10,5,"R1");
return 0;
}
class Rect : public Figure
{
public:
Rect(int l, int h,std::string Label) : Figure(l), _h(h),_Label(Label) {};
~Rect(){};
std:: vector<std::string> toString() const;
protected:
int _h;
int _l;
std::string _Label;
};
class Figure
{
public:
Figure(int l):_l(l){}
virtual std::vector<std::string> toStrings() const =0;
virtual ~Figure();
protected:
int _l;
};
これは標準エラーです。つまり、オブジェクトを作成しているクラスに対して、純粋な仮想メソッドが実装されていないことを意味します。この場合、Rectは 'std :: vector toStrings()const'を実装する必要があります。 –
'toString()' vs 'toStrings()' –