|home |print view |recent changes |changed February 23, 2017 | |You are 22.214.171.124 <- set your identity!
If you don't already have a development environment with Cevelop and a recent compiler (at least GCC 6.1.0) take care of this first. Here is a guide from CPl on how to do it: https://wiki.ifs.hsr.ch/CPlusPlus/ExW1
We will most likely need newer compilers later on in the module. Details about the specifc version will be supplied then.
If you don't have already done that install the Ctylechecker plug-in into your Cevelop IDE.
Import one of your exercise solutions from the C++ module and check it for problems reported by Ctylechecker or Constificator. Are the reports reasonable?
If you find any errors in the plug-ins let me know. We might be able to fix them!
For the following tasks write test cases first!
intas parameter and returns the next value (
incrementthat modifies the parameter as side-effect. Do you encounter any problems when calling
incrementin the presence of both overloads? Stick with the side-effect version for the following exercises.
incrementto accept parameters of arbitrary type and increments them - given they support the prefix increment operator. Start your test cases with double.
unsignedis well defined. Add an overload for this case that does not throw. Does it need to be a template specialization?
unsigned long) because the template has an exact match for the overload resolution unless you provide an overload for the specific type. Example: If you provide the overload for
unsigned long longand call
unsignedvariable as argument the template will be chosen instead of the
unsigned long longoverload. Therefore, try an alternative approach to tackle overflows. Create a predicate (as template)
falseby default but can and should be specialized for
unsignedtypes to be true. You can implement the predicate as variable, class or function template for that matter.
unsignedtypes there is still much code, at least it avoids duplication in the logic. As usually the standard library can help. Have a look at
is_unsignedtype trait. Can you implement your predicate with those?
incrementfunction? You might experience different outcome depending on your compiler. It might not be happy if you want to get
numeric_limitsfor your iterator. Adapt your
incrementfunction to also have the capability to take a second parameter to have a user-provided limit. Your previous tests should still remain working. Therefore, add a default argument to that parameter. You probably used comparisons and a
- 1operation to your limit. Does this restrict the iterators you can use with
Implement your own
Fraction type that can represent fraction numbers more precisely than the
-(unary and binary),
/. After every operation try to reduce
denominatorwhen appropriate in order to allow continous calculations that try to prevent overflows on these representational parts.
|home |print view |recent changes |changed February 23, 2017 |
|You are 126.96.36.199
<- set your identity!