C++ (programming   language):
What are some features,functions, or techniques thatprogrammers should avoid in            C++?
General Features of C++
This is not necessarily a good             thing
For example, there is explicit pointer arithmetic (as in C)
Some specific OO features of           C++
Classes can contain both data       and operations
Data and functions in classes       can be hidden
A class can be composed of       other classes
New classes can be obtained    from other classes
C++ allows all forms of   polymorphism:
coercion
overloading
pure polymorphism
parametric polymorphism:templates, (genericity in Eiffel)
Specific language features
Comments
Both C style comments /* .....  */ are allowed as well as comments starting with //
Can use /* ...*/ for multiple line          comments
// can be used as in line       comments
long numTribbles; // will       increase!
They can also be used as single        line comments
// This is a comment
// Every comment line must           start
// with a //
/*
// C++ comments can be        contained
// inside C style comments
*/
Programming recommendation
Always use // comments
This allows sections of code tobe commented out with /* ... */
Introduction to iostream
Input and output are not part of      the C++ language.
They are supported by the iostream library.
This predefines three streams           for I/O:
cin - standard input (terminal)
cout - standard output        (screen)
cerr - standard error
The << (put to) operatordirects output to a stream
The >> (get from) operatorretrieves data from a stream
A stream is a sequence of       characters.
Readability Advantages of C         over C++
According to : Carlos Oliveira
of the perceived problems in C is the lack of support for   object oriented features that are so common on the   developme...
programmers. Inheritance was one of them, used to  support object oriented    features. Overriddenmethods were also added ...
overloaded, so that manymath operations, and evenpunctuation such as “,” can      be overloaded by   programmers. Normal  ...
class based on one or more types. This allows for thecreation of containers, such  as the ones found in the  STL. Vectors,...
Conclusion
these features have a cost.  It becomes increasinglydifficult to understand what is going on in each line ofcode, unless t...
While C++ has some  features that might be  helpful, in general thebigger the C++ code base     the harder it is to unders...
perform refactoring). In  comparison, C is mucheasier to understand, andone can do a lot with tools such as ctags. It is n...
MELJUN CORTES - C++ Programming Lecture
MELJUN CORTES - C++ Programming Lecture
MELJUN CORTES - C++ Programming Lecture
MELJUN CORTES - C++ Programming Lecture
MELJUN CORTES - C++ Programming Lecture
MELJUN CORTES - C++ Programming Lecture
MELJUN CORTES - C++ Programming Lecture
MELJUN CORTES - C++ Programming Lecture
MELJUN CORTES - C++ Programming Lecture
MELJUN CORTES - C++ Programming Lecture
MELJUN CORTES - C++ Programming Lecture
Upcoming SlideShare
Loading in...5
×

MELJUN CORTES - C++ Programming Lecture

141

Published on

MELJUN CORTES - C++ Programming Lecture

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
141
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

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.
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×