CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Noob question

  1. #1
    Join Date
    Feb 2010
    Posts
    13

    Smile Noob question

    really simple question

    Is there anyway to overload the return value as I have tried to do below

    class currency
    {
    private Int64 Total;

    public Int64 currency
    {
    get
    {
    return (Total / 1000);
    }
    set
    {
    Total = (value * 1000);
    }
    }

    public Int32 currency
    {
    get
    {
    return (Int32)(Total / 1000);
    }
    set
    {
    Total = (Int64)(value * 1000);
    }
    }

    Thanks

  2. #2
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Noob question

    No, though you could wrap the int in your own class and use polymorphism.

    Also, you are doing integer division which is sure to cause problems soon. Currency should be handled using the decimal type.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured