MELJUN CORTES - C++ Programming Lecture
Upcoming SlideShare
Loading in...5
×
 

MELJUN CORTES - C++ Programming Lecture

on

  • 251 views

MELJUN CORTES - C++ Programming Lecture

MELJUN CORTES - C++ Programming Lecture

Statistics

Views

Total Views
251
Views on SlideShare
251
Embed Views
0

Actions

Likes
0
Downloads
1
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    MELJUN CORTES - C++ Programming Lecture MELJUN CORTES - C++ Programming Lecture Presentation Transcript

    • 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 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
    • programmers. Inheritance was one of them, used to support object oriented features. Overriddenmethods were also added to improve object oriented programs.
    • 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.
    • 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
    • Conclusion
    • these features have a cost. It becomes increasinglydifficult to understand what is going on in each line ofcode, unless the developers are very disciplined.
    • 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.
    • 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.