announcements
play

Announcements Its Co-op time C++: Architecture and Orientation - PDF document

Announcements Its Co-op time C++: Architecture and Orientation Conventions Wednesday, Sept 17 th , 4:00 pm 5:30 pm, 77- A190 Thursday, Sept 18 th , 12:00 pm 1:30 pm, 70- 1455 Friday, Sept 19 th , 1:00 pm 2:30


  1. Announcements • It’s Co-op time C++: Architecture and – Orientation Conventions – Wednesday, Sept 17 th , 4:00 pm – 5:30 pm, 77- A190 – Thursday, Sept 18 th , 12:00 pm – 1:30 pm, 70- 1455 – Friday, Sept 19 th , 1:00 pm – 2:30 pm, 76- 1125 – Friday, Sept 26 th , 1:00 pm – 2:30 pm, 76- 1125 – Tuesday, Oct 7 th , 1:00 pm – 2:30 pm, 76- 1125 – Wednesday, Oct 22 nd , 4:00 pm – 5:30 pm, 77- A190 • Job Fair – Wednesday, Oct 15, 1-6pm, Clark Gym Announcement Before we start • New exam dates: • Any questions on UML from last week? – Exam 1 – Tuesday, September 30 th – Exam 2 – Tuesday, October 28 th History of C++ History of C++ • 1969 – UNIX • Why bring this up – Created to play space wars – C is a “low level” system language – B (Basic Combined Programming Language) • Program as manipulator of memory • 1970 • All memory management done by hand – UNIX port to PDP-11 – C++ is not only based on C but is a proper • 1972 superset – C (rewrite of B) • If you can do it in C you can do it in C++ • Early 1980s • Added Object Oriented paradigm. – C++ invented as a “superset of C” – Take home message: C++ is not Java!!!!

  2. File Structure File Structure • One class, two files • Cpp – The C Preprocessor – Header file (.h) – Reads all C code before compilation • Contains class declaration (interface++) – Directives – Source file (.c, .cpp, .C, .cxx) • Including text files • Contains class definition – #include • Conditional compilation – implementation of methods – #if / #ifdef / #ifndef / #else / #endif • Macros – #define File Structure Compilation – Java Other Java classes • #include “filename.h” – Inserts text from one file into another before Foo.java javac Foo.class compilation java Foo Foo.java – Contain info needed by other files to compile JVM • Libraries – function signature (platform Java • Classes – class interface (I.e. header file) independent) (platform compiler dependent) Compilation – C++ Compilation – Java vs C++ Other object linked • Java • C++ Foo.C – Compilation unit is the – Compilation unit is the Foo.o g++ foo.o .. class file g++ Foo.C – External classes – External classes located using a require header and Foo.exe Object file predefined path precompiled object file linking Foo.h C++ (platform – JVM needed to execute – Executable file need to compiler dependent) execute. Executable file (platform dependent)

  3. Compilation – C++ Using C Libraries • Use CC/g++ to compile individual files into • Like Java, C/C++ has a multitude of useful object files auxillary functions and classes in libraries • Use CC/g++ to link object files into an • Unlike Java, C++ does not have the notion executable file of packages. – Need to specify executable name, otherwise • C / C++ also doesn’t have nice javadocs will be named a.out • Use man instead • Run the executable file. Using C Libraries Managing C++ Projects • make • Library header files must be #included for compilation – Files to be compiled – Compiler options – #include “mylib.h” – Libraries – #include <math.h> – Dependencies • Library object files must be linked when linking. – Make will build an executable – makemake – Makes Makefiles! – CC file file file –lm mylib.o – Lab 1 Running C++ Executables Anatomy of a class • No top level “main” class • Let’s take a look at a header and source file – main() in its own file for a C++ class, shall we? – main (int argc, char *argv[]) • If there is a problem… – Bus error (core dumped) – Segmentation fault (core dumped) • Questions?

  4. Anatomy of a class • Things to remember – .h & .C files – No package, but namespaces – C++ Style guidelines – Comment, comment, comment • Questions?

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend