Click here to Skip to main content
Click here to Skip to main content

Calculator VC++_2005

, 10 Jun 2007
Rate this:
Please Sign up or sign in to vote.
A simple calculator based on inheritance class
Screenshot - calculator.png

Introduction

A simple calculator with managed visual c++ in studio 2005.

Background


Using the code

I used a class for items(item.h) . In this class are stored the two number into property and the result:

//
    property double nr1;
    property double nr2;

//

The operations like :asin,cos,power,pi,plu,divide,sqrt etc. are edited into inherited class from items:

//
#pragma once
#include "Items.h"

using namespace System;

public ref class asinus : public Items
{
public:

    asinus(void)
    {
        
    }

    double^ asin(double a)
    {        
        return Math::Asin(a);
    }
    
};


// 

<<>>In the base class i used 6 boolean variable for the precedent operation:
>

        bool plus;
        bool minus;
        bool produs;
        bool divide;
        bool sin;
        bool prec;

For button equal:

        private: System::Void btnegal_Click(System::Object^  sender, System::EventArgs^  e) 
         {                             
             prec = false;

             if(plus == true)
             {                 
                 this->txtRes->Text = Convert::ToString(p.aduna(i.nr1,i.nr2));
             }
             else if(minus == true)
             {                 
                this->txtRes->Text = Convert::ToString(m.scadere(i.nr1,i.nr2));
             }
             else if(produs == true)
             {                 
                this->txtRes->Text = Convert::ToString(pr.inmultire(i.nr1,i.nr2));
             }
             else if(divide == true)
             {                 
                this->txtRes->Text = Convert::ToString(d.impartire(i.nr1,i.nr2));
             }
         }


I have a function for operaton click:

    private: System::Void Operation_Click(System::Object^  sender, System::EventArgs^  e) 
         {            
             if(prec == false)
             {
                i.nr1 = Convert::ToDouble(this->txtRes->Text);                    
             }
             if(prec == true)
             {
                i.nr2 = Convert::ToDouble(this->txtRes->Text);        
             }                                   
         }


History

The first version...keeping for future ...

All ze best for all programmers ...Smile | :)
The programming no have limits, only limit is imposed by our minds and hidden benefits ...

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Ionescu Marius
Web Developer
Romania Romania
Programming in all language.

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web04 | 2.8.141022.2 | Last Updated 10 Jun 2007
Article Copyright 2007 by Ionescu Marius
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid