C/C++ For Linux <ul><ul><li>Session 7 </li></ul></ul><ul><ul><li>C++ - Session 1 </li></ul></ul>
Outline <ul><li>Why C++? </li></ul><ul><li>New easier way to code old concepts </li></ul><ul><li>Classes  </li></ul><ul><l...
Object-Oriented Concepts <ul><li>Instance vs type </li></ul><ul><li>Isa </li></ul><ul><li>Not centered on procedure (flow ...
Central Axes of our Discussion <ul><li>Abstraction/hiding made easier </li></ul><ul><li>Object behavior modification </li>...
References <ul><li>An object naming </li></ul><ul><li>Declaration </li></ul><ul><li>Lvalue assignment from const,  non-con...
Remember Functions? <ul><li>Overloading </li></ul><ul><ul><li>Function signature </li></ul></ul><ul><ul><li>const </li></u...
Remember Scopes? <ul><li>Namespaces </li></ul><ul><ul><li>A scope unrelated to any instances </li></ul></ul><ul><ul><li>De...
Class <ul><li>An object type </li></ul><ul><li>A scope </li></ul>
Class as Object type <ul><li>Define behavior/interface: </li></ul><ul><ul><li>Member variables </li></ul></ul><ul><ul><li>...
Class as a Scope <ul><li>Private - Not accessible from outside that class </li></ul><ul><li>Public - Accessible from outsi...
Creation/Deletion <ul><li>Constructors </li></ul><ul><li>Destructors </li></ul><ul><li>How they get invoked </li></ul><ul>...
Static Members <ul><li>Class-wide, do not operate on an instance </li></ul><ul><li>“public”ness still applies (outside ini...
Structures with an attitude <ul><li>Now object types </li></ul><ul><li>Now have member methods </li></ul><ul><ul><li>No ac...
Automake example <ul><li>Write your code </li></ul><ul><li>Makefile.am </li></ul><ul><ul><li>SUBDIRS </li></ul></ul><ul><u...
Automake example-cont'd <ul><li>Modify output </li></ul><ul><ul><li>Rename to configure.ac </li></ul></ul><ul><ul><li>AM_I...
Upcoming SlideShare
Loading in …5
×

Sysprog 7

701 views
602 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
701
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
11
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Sysprog 7

  1. 1. C/C++ For Linux <ul><ul><li>Session 7 </li></ul></ul><ul><ul><li>C++ - Session 1 </li></ul></ul>
  2. 2. Outline <ul><li>Why C++? </li></ul><ul><li>New easier way to code old concepts </li></ul><ul><li>Classes </li></ul><ul><li>More on old concepts renewed </li></ul><ul><li>Automake example </li></ul>
  3. 3. Object-Oriented Concepts <ul><li>Instance vs type </li></ul><ul><li>Isa </li></ul><ul><li>Not centered on procedure (flow control) </li></ul><ul><li>Centered on object: flow possibilities explode on global level </li></ul><ul><li>Consider IPC example – is OO doable in C? </li></ul>
  4. 4. Central Axes of our Discussion <ul><li>Abstraction/hiding made easier </li></ul><ul><li>Object behavior modification </li></ul><ul><ul><li>common/specific </li></ul></ul><ul><li>Generic programming </li></ul><ul><ul><li>type independence </li></ul></ul><ul><li>Inter-object interaction </li></ul><ul><ul><li>Design </li></ul></ul>
  5. 5. References <ul><li>An object naming </li></ul><ul><li>Declaration </li></ul><ul><li>Lvalue assignment from const, non-const </li></ul>
  6. 6. Remember Functions? <ul><li>Overloading </li></ul><ul><ul><li>Function signature </li></ul></ul><ul><ul><li>const </li></ul></ul><ul><li>Default arguments </li></ul><ul><ul><li>Ambiguity with overloading </li></ul></ul>
  7. 7. Remember Scopes? <ul><li>Namespaces </li></ul><ul><ul><li>A scope unrelated to any instances </li></ul></ul><ul><ul><li>Declaration </li></ul></ul><ul><ul><li>Using </li></ul></ul><ul><li>Scoping operator </li></ul><ul><li>Can be nested </li></ul>
  8. 8. Class <ul><li>An object type </li></ul><ul><li>A scope </li></ul>
  9. 9. Class as Object type <ul><li>Define behavior/interface: </li></ul><ul><ul><li>Member variables </li></ul></ul><ul><ul><li>Member methods </li></ul></ul><ul><ul><li>Can define creation/deletion behavior </li></ul></ul>
  10. 10. Class as a Scope <ul><li>Private - Not accessible from outside that class </li></ul><ul><li>Public - Accessible from outside the class </li></ul><ul><li>:: on class-wide things </li></ul><ul><li>.,-> on instance </li></ul><ul><li>Enumerations, consts, nested classes/structures </li></ul>
  11. 11. Creation/Deletion <ul><li>Constructors </li></ul><ul><li>Destructors </li></ul><ul><li>How they get invoked </li></ul><ul><ul><li>Declaration </li></ul></ul><ul><ul><li>scoping </li></ul></ul><ul><li>Malloc/free with an attitude: </li></ul><ul><ul><li>new </li></ul></ul><ul><ul><li>delete </li></ul></ul>
  12. 12. Static Members <ul><li>Class-wide, do not operate on an instance </li></ul><ul><li>“public”ness still applies (outside initialization) </li></ul><ul><li>Variables must be initialized </li></ul><ul><li>Methods can not operate on an instance, i.e. can not access non-static members. </li></ul>
  13. 13. Structures with an attitude <ul><li>Now object types </li></ul><ul><li>Now have member methods </li></ul><ul><ul><li>No access level </li></ul></ul><ul><li>Anonymous structures and unions </li></ul><ul><li>To be continued </li></ul>
  14. 14. Automake example <ul><li>Write your code </li></ul><ul><li>Makefile.am </li></ul><ul><ul><li>SUBDIRS </li></ul></ul><ul><ul><li>Building Libraries </li></ul></ul><ul><ul><li>Building executables </li></ul></ul><ul><ul><ul><li>Linking against your library </li></ul></ul></ul><ul><ul><ul><li>Including your headers </li></ul></ul></ul><ul><li>autoscan </li></ul>
  15. 15. Automake example-cont'd <ul><li>Modify output </li></ul><ul><ul><li>Rename to configure.ac </li></ul></ul><ul><ul><li>AM_INIT_AUTOMAKE </li></ul></ul><ul><ul><li>AC_PROG_LIBTOOL </li></ul></ul><ul><li>autoreconf --install </li></ul><ul><li>./configure </li></ul><ul><li>Make </li></ul>

×