Click here to Skip to main content
13,042,307 members (93,061 online)
Click here to Skip to main content
Add your own
alternative version


12 bookmarked
Posted 10 Jun 2007

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


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


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


    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);


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

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


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


About the Author

Ionescu Marius
Web Developer
Romania Romania
Programming in all language.

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170713.1 | Last Updated 10 Jun 2007
Article Copyright 2007 by Ionescu Marius
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid