GithubHelp home page GithubHelp logo

cpp_exercises's Introduction

cpp_exercises's People

Contributors

jumang4423 avatar

Watchers

 avatar  avatar

cpp_exercises's Issues

Ex06 - q2: Incorrect

In ex06 - q2, the class Polygon should implement the interface Shape2D. (it should inherit from Shape2D and implements its pure virtual functions).

Ex07 - q1: Problems

@jumang4423 Please add try / catch blocks in the main function. (We have a guarantee that in the event of an uncaught exception, std::terminate is being called - thus the error messages that you got).

Ex01 - q2

@jumang4423 for ex01-q2, the (second) formula defining the pmf is recursive. Thus the function binomialPMF can be defined as a recursive function. Can you please try? (the implementation is 3 lines, including the base cases)

Ex05 - q2, q3: Problems

@jumang4423 In ex05:

  • The assignment operator is leaking memory (you need to delete[] before writing _items = new double[])
  • The move assignment operator is missing.

Ex08 and 09

@jumang4423

  • It would have been cleaner to separate ex08 and ex09, even if it is clear that MatNxN is a generalization of Mat4x4
  • In the template class, instead of N, 4 is used in several instances
  • The compound operators (operator+=, operator-=, operator*=) should return by reference (otherwise they can't be chained)
  • The unary "-" operator should not modify its argument
  • The const version of operator()(int, int) seems to be missing

Ex10: Problems

@jumang4423
Q1:

  • is_numeric instead of is_numberic?
  • if the token is a "(", there is no need to push it, just ignore it

Q2:

  • header file without guards to prevent for multiple inclusions
  • it is not a good idea to have functions defined in a header file unless if they are inline

It is OK to include bits/stdc++.h in competitive programming, but otherwise, it is better to include only what is really necessary.

Ex06 - q1: Problems

@jumang4423

  • Shape2D (ex06) is an interface. Its member functions should be pure virtual. This is not the case in your implementation.
  • The pure virtual functions create and clone are missing in Shape2D
  • No need of the file Shape2D.cpp (there is no implementation for an interface)
  • The tests are limited. Interfaces are manipulating via pointers (or references). Without pointers to the base class (the interface), there is no point in having virtual functions.

Ex07 - q2: Problems

In ex07 - q2 (exception), the only changes should be:

  • in example where you replace FILE* with LogFile
  • main where you add a try / catch block

There is no need to rewrite, for example, doSomeComputation.
Similarly, the LogFile object should be a local object in the function example. We are experimenting with releasing resources while manipulating exceptions.

Ex04: Possible improvements

@jumang4423 The const-correctness for ex04 looks good.

It is possible to improve the inc_ functions by considering the number of days per month, and the number of months per year.

Ex01 - q1

@jumang4423 ex01-q1 looks good.
Only a few minor things:

  • we need to allocate num_digit+2 for a negative number but only num_digit+1 otherwise
  • when you add a minus for a negative number, shouldn't it be putMinus(str, getDigit(num)+1);? I.e. you want the terminal '\0' to be moved as well (I think that with the current implementation it gets overwritten). Could you please check?

The code is very well written (and documented).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.