OOCP3-10

//BCA Support //www.bcasupport.xyz #include <iostream.h> #include <conio.h> class celcius { float temp; public: void getdata(float x) { temp=x; } void show() { cout<<"\nTemperature (C) : "<<temp; } float getcelcius() { return temp; } }; class fahrenheit { float temp; public: fahrenheit() {} fahrenheit(celcius c) { temp=(c.getcelcius()*1.8)+32; } void getdata(float x) { temp=x; } void show() { cout<<"\nTemperature (F) : "<<temp; } operator celcius() { celcius c; c.getdata((temp-32)/1.8); return c; } }; int main() { clrscr(); fahrenheit f; celcius c; cout<<"\nCelcius to Fahrenheit-"; c.getdata(37.7778); c.show(); f=c; f.show(); cout<<"\n\nFahrenheit to Celcius-"; f.getdata(98.6); f.show(); c=f; c.show(); getch(); return 0; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.