Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

MELJUN CORTES - C++ Programming Lecture

277 views

Published on

MELJUN CORTES - C++ Programming Lecture

  • Be the first to comment

  • Be the first to like this

MELJUN CORTES - C++ Programming Lecture

  1. 1. C++ (programming language):
  2. 2. What are some features,functions, or techniques thatprogrammers should avoid in C++?
  3. 3. General Features of C++
  4. 4. This is not necessarily a good thing
  5. 5. For example, there is explicit pointer arithmetic (as in C)
  6. 6. Some specific OO features of C++
  7. 7. Classes can contain both data and operations
  8. 8. Data and functions in classes can be hidden
  9. 9. A class can be composed of other classes
  10. 10. New classes can be obtained from other classes
  11. 11. C++ allows all forms of polymorphism:
  12. 12. coercion
  13. 13. overloading
  14. 14. pure polymorphism
  15. 15. parametric polymorphism:templates, (genericity in Eiffel)
  16. 16. Specific language features
  17. 17. Comments
  18. 18. Both C style comments /* ..... */ are allowed as well as comments starting with //
  19. 19. Can use /* ...*/ for multiple line comments
  20. 20. // can be used as in line comments
  21. 21. long numTribbles; // will increase!
  22. 22. They can also be used as single line comments
  23. 23. // This is a comment
  24. 24. // Every comment line must start
  25. 25. // with a //
  26. 26. /*
  27. 27. // C++ comments can be contained
  28. 28. // inside C style comments
  29. 29. */
  30. 30. Programming recommendation
  31. 31. Always use // comments
  32. 32. This allows sections of code tobe commented out with /* ... */
  33. 33. Introduction to iostream
  34. 34. Input and output are not part of the C++ language.
  35. 35. They are supported by the iostream library.
  36. 36. This predefines three streams for I/O:
  37. 37. cin - standard input (terminal)
  38. 38. cout - standard output (screen)
  39. 39. cerr - standard error
  40. 40. The << (put to) operatordirects output to a stream
  41. 41. The >> (get from) operatorretrieves data from a stream
  42. 42. A stream is a sequence of characters.
  43. 43. Readability Advantages of C over C++
  44. 44. According to : Carlos Oliveira
  45. 45. of the perceived problems in C is the lack of support for object oriented features that are so common on the development of desktopapplications. For example, C lacks the concept of a typethat encapsulates code and data. While it is possible to program in an object oriented style in C, it is
  46. 46. programmers. Inheritance was one of them, used to support object oriented features. Overriddenmethods were also added to improve object oriented programs.
  47. 47. overloaded, so that manymath operations, and evenpunctuation such as “,” can be overloaded by programmers. Normal functions can also be overloaded, by providing versions that differ on the number and type of arguments.
  48. 48. class based on one or more types. This allows for thecreation of containers, such as the ones found in the STL. Vectors, maps, and multimaps can all becreated by adding a type as a parameter for template instantiation
  49. 49. Conclusion
  50. 50. these features have a cost. It becomes increasinglydifficult to understand what is going on in each line ofcode, unless the developers are very disciplined.
  51. 51. While C++ has some features that might be helpful, in general thebigger the C++ code base the harder it is to understand due to these issues.
  52. 52. perform refactoring). In comparison, C is mucheasier to understand, andone can do a lot with tools such as ctags. It is not a surprise that large scaleprojects such as the Linux kernel use C without any problem.

×