1 / 4

Header files (answers to jit-anonymous questions)

This text provides an explanation of header files in C++, the differences between STL classes and libtapestry classes, as well as an overview of system shells and their configuration.

Download Presentation

Header files (answers to jit-anonymous questions)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Header files (answers to jit-anonymous questions) • Angle brackets <> specify header files found in standard locations, double quotes “” specify current directory (or non standard location) • <iostream.h>, <ctype.h> • “ctimer.h”, “date.h” • in new versions of C++, the .h isn’t used for standard C++ classes, e.g., <iostream>, <string>, STL <vector> • on our system these files just use #include <iostream.h>, but could pre-compile or otherwise optimize the headers • on other system using the .h puts classes into the global namespace, otherwise must qualify use: std::cout vs cout

  2. “hello” “hello” “hello” Standard/STL classes vs libtapestry classes • libtapestry strings aren’t as efficient, e.g., no sharing on assignment • reference counted, shared storage • copy on write • always copy (libtapestry) • shared vs static libraries • static code stored in executable when compiled • shared/dynamic linked when program run • advantages? string a = “hello”; string b = a; libtapestry.a a b standard (libg++.so) a b b[0] = ‘j’; // what happens?

  3. STL classes (e.g., vector) • In general, the STL classes aren’t safe, e.g., bad index not checked • on our systems, a “safe” version of classes can be used by using #define __STL_DEBUG before any #include • specific differences in STL vector vs libtapestry vector STL libtapestry • size() length() • push_back() append() • append/push_back works differently: size() in libtapestry is number of times append called • libtapestry vector, map, stack, queue are as efficient as STL classes (sometimes more efficient) and are safe

  4. Using the system, dot files • The shell is the program you type commands at • different shells: sh, csh, bash, ksh, tcsh • use tcsh unless you’re positive you want something else • the shell looks at your PATH environment variable to determine where commands you type are found • uses directories specified in left-to-right order setenv PATH /afs/acpub/project/cps/bin:${PATH} • also /bin/sh variable called path (lower case) set differently • .cshrc file, used each time you start a shell • .login file, used when you log in • .emacs file, used when you launch emacs/xemacs

More Related