|
-
April 6th, 2010, 10:47 PM
#1
Generic methods and parameter types
I'm writing a math class. It has a bunch of methods in it, some are quite long. My constructor and methods only accept an int as a parameter right now. I want to extend this to include long's and BigInteger's and in some cases double's. But I don't want to have to rewrite every method for each data type. I tried a bunch of things, including generics, but I kept running into incomparable type problems when i started trying to operate on the variables even after I cast them as a specific datatype. My prof said it would be possible using generics but I cant seem to get it to work. Has anyone ran across this problem before?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|