private void Form1_Load(object sender, EventArgs e) { //int x; The compiler allocates memory for the variable in stack EngineClass EnginObject; // it is only a declaration CarObject = new CarClass(); EnginObject = new EngineClass(); // the compiler allocates memory for variable in heap // and it is completely reclaimable // as a side effect of creating this object, constructor will run EnginObject.SetNoofcylanders(2); EnginObject.SetVolumeCC(5); //EnginObject.SetEnginetype(false); EnginObject.SetTorque(5); EnginObject.SetHorsepower(2200); MessageBox.Show(EnginObject.MakeString()); }
private void button2_Click(object sender, EventArgs e) { MessageBox.Show(TempObject.MakeString()); }