


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



#include
cout<<"The series current is : "<< Rcomponent.getI()<<endl; } friend void operator += (Series_Circuit& sc, Resistor& res); friend void operator â= (Series_Circuit& sc, Resistor& res); }; void operator += (Series_Circuit& sc, Resistor& res) { float current = 0. 0 F; current = sc.Rcomponent.getV() / (sc.Rcomponent.getR() + res.getR()); sc.Rcomponent.setR(sc.Rcomponent.getR() + res.getR()); sc.Rcomponent.setI(current); } void operator â= (Series_Circuit& sc, Resistor& res) { float current = 0. 0 F; current = sc.Rcomponent.getV() / (sc.Rcomponent.getR() â res.getR()); sc.Rcomponent.setR(sc.Rcomponent.getR() â res.getR()); sc.Rcomponent.setI(current); } void main() { char option = 'y'; float resistance = 0. 0 f; float current = 0. 0 f; //Initial setting cout<<"Enter the Initial Resistance (in ohms) : "; cin>>resistance; cout<<"Enter the initial Current (in amperes) : "; cin>>current; Series_Circuit circuit(resistance, current); while( 1 ) { cout<<"Add another (y/n) : "; cin>>option; if(option == 'n') break; cout<<"Enter the Resistance (in ohms) : "; cin>>resistance; Resistor Temp(resistance, 0. 0 F); circuit += Temp; }
c:\documents and settings\usman.younis\my documents... 2010\Projects\op_overload2\op_overload2\opover.cpp 1 #include