Código
#include <iostream> using namespace std; class Articulo{ public: virtual float getCosto()=0; void setBase1(float b1){ Base1= b1; } void setBase2(float b2){ Base2=b2; } protected: float Base1; float Base2; }; class Menor: public Articulo{ public: float getCosto(){ return (Base1 * 15) /100; } }; class Mayor: public Articulo{ float getCosto(){ return (Base2 * 25) /100; } }; int main (void){ Menor PreM; Mayor PreMay; PreM.setBase1(80); cout<<"El precio menor es:"<<PreM.getCosto()<<endl; PreMay.setBase2(50); cout<<"El precio mayor es:"<<PreMay.getCosto()<<endl; return 0; }
In function ‘int main()’:
articulo.cpp:24:11: error: ‘virtual float Mayor::getCosto()’ is private
float getCosto(){
^
articulo.cpp:36:46: error: within this context
cout<<"El precio mayor es:"<<PreMay.getCosto()<<endl;