473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Data types like Money or Price

bb
Hi,

Are there any open source data types ( c++ classes ) for Money and/or
Price that I can inherit and customize for my use instead of writing
from the scratch?

Any help would be much appreciated.

Thanks.

Nov 5 '07 #1
9 4914
bb wrote:
Hi,

Are there any open source data types ( c++ classes ) for Money and/or
Price that I can inherit and customize for my use instead of writing
from the scratch?

Any help would be much appreciated.

Thanks.
Here they are:

class Money
{
};

class Price
{
};
Nov 5 '07 #2
typedef int?

Besides, what do you want those classes to do? I doubt there is
anything you'd find that suits your needs.

Nov 5 '07 #3
typedef int?

Then my 0.02$ will be worth 0...
Nov 6 '07 #4
On Nov 6, 11:02 am, "Gernot Frisch" <M...@Privacy.netwrote:
typedef int?

Then my 0.02$ will be worth 0...
Or 2 ;) Or whatever accuracy.

Nov 6 '07 #5
There was an attempt to submit a fixed-point decimal library to Boost,
but it was not accepted: http://archives.free.net.ph/message/...ab8488.en.html

Maybe you can dig the source somewhere.

Nov 6 '07 #6
On Tue, 06 Nov 2007 18:08:40 +0000, Zeppe wrote:
>bb wrote:
>I have started hand coding all the required operators, bounds checking
etc. specific to my project requirement. ( inheritance heirarchy :
MyDouble <- MyPrice <- MyMoney )

I don;t really want to know why the Money ntherits from the price :)
.... and MyPrice from MyDouble. Isn't the primary purpose of a Money
class to avoid double?
>Check out this if you want
http://quantlib.org/reference/class_...1_1_money.html
Thank you, looks very professional - and it even has a Date class :-)
--
Roland Pibinger
"The best software is simple, elegant, and full of drama" - Grady Booch
Nov 6 '07 #7
On 2007-11-05 04:26:27 -0500, anon <an**@no.nosaid:
bb wrote:
>Hi,

Are there any open source data types ( c++ classes ) for Money and/or
Price that I can inherit and customize for my use instead of writing
from the scratch?

Any help would be much appreciated.

Thanks.

Here they are:

class Money
{
};

class Price
{
};
You didn't declare virtual destructors. Your classes may have troubles
with inheritance. :)

--

-kira

Nov 6 '07 #8
On Nov 6, 5:40 pm, Puppet_Sock <puppet_s...@hotmail.comwrote:
On Nov 6, 9:16 am, bb <muralibal...@gmail.comwrote:
[snip]
I have started hand coding all the required operators,
bounds checking etc. specific to my project requirement. (
inheritance heirarchy : MyDouble <- MyPrice <- MyMoney )
If you've got a careful and complete specification of how
your money class is supposed to behave, you are already
much farther along than the typical application involving
money. Eventually most such projects wind up here asking
how they get the roundoff of pennies correct. It's a lot
of fun telling them that I can't quite read their spec
from where I'm sitting, then having them say they don't
have a spec. Usually they get confused at that point.
At least in the EU, the spec is a given; EU directives say
exactly how you have to round the cents.
Just a suggestion: Consider whether you really need that
inheritance. Consider whether what you really want is a
Currency class. (Or maybe call it Cash or Money or some
such.) Then when you have a price you can make that class
contain a Currency as a data member.
His inheritance doesn't make any sense at all. Generally
speaking, you probably need: a general Decimal class, to handle
the basic arithmetic; a monitary value class (MoneyAmount, or
some such) which has a Decimal in its implementation (but
controls rounding, etc., in a specific way), and a third class
which has both a MoneyAmount and a currency indicator (Euro,
GBP, USD, etc.).

[...]
Without getting too much into your specific app it's hard to
know whether the inheritance is the correct approach.
These are values, so inheritance is almost certainly the wrong
approach.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Nov 7 '07 #9
Kira Yamato wrote:
On 2007-11-05 04:26:27 -0500, anon <an**@no.nosaid:
>bb wrote:
>>Hi,

Are there any open source data types ( c++ classes ) for Money and/or
Price that I can inherit and customize for my use instead of writing
from the scratch?

Any help would be much appreciated.

Thanks.

Here they are:

class Money
{
};

class Price
{
};

You didn't declare virtual destructors. Your classes may have troubles
with inheritance. :)
Oh damn... They are not tested - thats why ;)
Nov 7 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: D. Shane Fowlkes | last post by:
I have a couple of fields in SQL Server which are defined as "Money". One is "Quantity" and the other is "Unit Price". Unit Price I can understand being defined as "money" but I'm not sure why the...
5
by: DC Gringo | last post by:
I am having a problem reading a simple update to the database. Basically I'm testing a small change to the pubs database -- changing the price of the Busy Executive's Database Guide from 19.99 to...
7
by: bartvanhemelen | last post by:
Here's what I want to do: I've got a table with orders, each order has a specific discountrate (an int, which represents a percentage). Each order consists of 1 or more items in another table, each...
11
by: mesut demir | last post by:
Hi All, When I create fields (in files) I need assign a data type like char, varchar, money etc. I have some questions about the data types when you create fields in a file. What is the...
4
by: Ronald S. Cook | last post by:
We're designing the data model for a project. The app will be in .NET, the database will be in SQL Server 2005. I'm a little confused on type conversion between the two and which I should...
1
by: Alex | last post by:
Hi, I have three different data types coming out of my SQL tables that I need to align with my VB code and the data set properties. I'm getting an error message that reads "SQL exception...
1
by: sampalmer21 | last post by:
Hi, I'm creating a database application using c# and ado.net with winforms controls. In sql there is a data type called money which stores values in the format xx.xxxx, this is not in the typical...
7
by: erikcw | last post by:
Hi, I'm working on a web application where each user will be creating several "projects" in there account, each with 1,000-50,000 objects. Each object will consist of a unique name, an id, and...
1
by: rockchicx23 | last post by:
i have to develop this snack machine program that makes you chose a snack put money in and give change here is my code so far, what do i use so the program compare the price and money deposited, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.