I all ready completed and ran a program that works fine in Python but now I'm looking to convert that code to C++ in Eclipse. I thought I would be able to import this code than have some miracle conversion take place. Is this possible or does the whole code need to be transfered in C++ language? keep in mind I'm just a rookie at all this. Here is my code:
from datetime import date import exceptions import string now = date.today class Negative( exceptions.Exception ): '''A user-defined exception class.''' def __init__( self, val ): self.val = val return def __str__( self ): print "Bad amount. You typed '%s' Number has to be positive." %\ self.val class Overdrawn( exceptions.Exception ): def __init__( self, val ): self.val = val return def __str__( self ): print "You are attempting to create a balance overdrawn by %s" % self.val class Account: def __init__( self, initial ): '''Initializes the account data.''' self.balance = initial print ' (Initializing; balance is %s) ' % self.balance def deposit( self, amt ): '''Deposit amt into account''' if amt < 0: raise Negative( amt ) self.balance = self.balance + amt print " (Depositing %s; new balance is %s) " % ( amt, self.balance ) # When this deposit is created, it # adds to the balance def withdraw( self, amt ): '''Withraw amt from account''' if amt < 0: raise Negative( amt ) if amt >= self.balance: raise Overdrawn( self.balance - amt ) self.balance = self.balance - amt print " (Withdrawing %s; new balance is %s) " % ( amt, self.balance ) # When this deposit is created, it # subtracts from the balance def getbalance( self ): '''Return the current balance of this account.''' return self.balance def printmenu(): print "please select a number" print "1 Deposit" print "2 Withdraw" print '3 Balance' print '4 Done'