|home |print view |recent changes |changed February 22, 2018 | |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 7.2.x) take care of this first. Here is a guide from CPl on how to do it: https://wiki.ifs.hsr.ch/CPlusPlus/ExW1
It might be likely that need newer (gcc 7.3/clang 5) compilers later on in the module. Details about the specific version will be supplied then.
You need to update your Cevelop installation for the 1.9 release and If you don't have already done that install the Ctylechecker plug-in into your Cevelop IDE.
Again, it might be that we ask you to update Cevelop or install an additional beta-plug-in(-version) during the semester for specific exercises.
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 and
std::numeric_limitsprovides a corresponding maximum value. 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
denominatoras the largest possible integral type.
-(unary and binary),
/. After every operation try to reduce
denominatorwhen appropriate. This allows continuous calculations that try to prevent overflows on these representational parts (GCD algorithm).
At the end of the C++ module you had an assignment in the exercises to create a
vector-like container that features the capabilities to access its elements with negative indices (https://wiki.ifs.hsr.ch/CPlusPlus/ExW12). In the C++ Advanced module we will have an in-depth look at the implementation of bounded buffer container. We will expect that you are familiar and can easily implement containers like the
dynArray example. Revisit the implementation of this task, implement it again or study the code carefully, in order to be properly prepared for the upcomming testat assignments.
|home |print view |recent changes |changed February 22, 2018 |
|You are 126.96.36.199
<- set your identity!