40 likes | 52 Views
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.
E N D
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
“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?
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
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