Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
cppPyFoodVatTip
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//g++ 7.4.0 //cppPyFoodVatTip //this code is created by Rezaul Hoque on August 22,2022; update: 6:46 //contact: jewelmrh@yahoo.com; Dhaka, Bangladesh,https://rezaulhoque.wordpress.com;https:hoquestake.blogspot.com //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; #include <iostream> #include <string> #include <vector> class Food{ std::string name; public: Food(){} Food(std::string n){ this->name=n;} ~Food(){} std::string getN(){return name;} void nam(){ std::cout<<getN();} }; class Package: public Food{ int price,qty; public: Package (){} Package (std::string n,int p,int q): Food(n),price(p),qty(q){} ~Package(){} int getP(){return price;} int getQ(){return qty;} int cost(){ return price*qty;} }; class VatCo{ float vat,total; int tip; public: VatCo(){} VatCo (float v,int t,float to){vat=v; tip=t; total=to;} float getV(){return vat;} int getTip(){return tip;} float getTo(){return total;} virtual float convert()=0; }; class NoVat:public VatCo{ public: NoVat(){} NoVat(float v,int t,float to):VatCo(v,t,to){} ~NoVat(){} float convert(){ return getTip()+getTo();} }; class WithVat: public VatCo{ public: WithVat(){} WithVat(float v,int t,float to):VatCo(v,t,to){} ~WithVat(){} float convert(){ return getTip()+getTo()+getTo()*getV();} }; int main() { Package* p[3]; p[0]=new Package("Dal Roti",25,1); p[1]=new Package("Parota Korma",120,1); p[2]=new Package ("Naan Lotpoti",50,1); for(int i=0;i<3;i++){ std::cout<<p[i]->getN()<<" "<<p[i]->getP()<<" "<<p[i]->getQ()<<"\n"; } return 0; }
g++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 0.41 sec, absolute running time: 0.14 sec, cpu time: 0.01 sec, memory peak: 6 Mb, absolute service time: 0,65 sec
latest
|
history
Dal Roti 25 1 Parota Korma 120 1 Naan Lotpoti 50 1