Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class IConverter {
- public:
- virtual double convertto(double value) = 0;
- virtual double convertfrom(double value) = 0;
- };
- class Kconverter : public IConverter{
- public:
- virtual double convertto(double degrees) override{
- return degrees + 273.15;
- }
- virtual double convertfrom(double kelvin) override{
- return kelvin - 273.25;
- }
- };
- class FConverter : public IConverter {
- public:
- virtual double convertto(double degrees) override{
- return (degrees * 9/5)+32;
- }
- virtual double convertfrom(double far) override{
- return far - (9/5)+32 ;
- }
- };
- int main(){
- setlocale(LC_ALL, "Russian");
- Kconverter k;
- FConverter f;
- cout << k.convertto(5) << endl;
- cout << f.convertto(5) << endl;
- cout << k.convertfrom(5) << endl;
- cout << f.convertfrom(5) << endl;
- return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement