Operator Function Example scope resolution scope: : name

Size: px
Start display at page:

Download "Operator Function Example scope resolution scope: : name"

Transcription

1 Appendix A C++ Operators The relative precedence of the operators is shown, in decreasing order, in Table A.I where operators with the same precedence appear in the same "box". In the "example" column, exp stands for "expression", lvalue denotes an expression yielding an lvalue and explist stands for a comma-separated list of expressions. Operator Function Example scope resolution scope: : name. resolution in global scope : : scope: : name member selection cjassobject. membername -> member selection cjassobjectpointer. membername [] subscript pointer [exp 1 () function call exp (explist) typeid type identification typeid{type) typeid run-time type identifica- typeid (exp) tion dynamic_cast dynamic cast dynamic _cas t<type> (exp) static - cast static cast static _cast<type> (exp) reinterpret_cast reinterpret cast reinterpret_cast<type> (exp) const - cast const cast const _cast<type> (exp) type {) value construction double {'c') ++ post increment lvalue++ -- post decrement lvalue-- 265

2 266 APPENDIX A. C++ OPERATORS Operator Function Example sizeofo size of object or type sizeof(exp) ++ pre increment ++lvalue -- pre decrement --lvalue - bitwise complement - exp! logical not!exp - unary minus -exp + unary plus +exp & address of &lvalue * dereference *pointer new allocate and construct new (exp) type(explist) new [ ] allocate and construct ar- new [] (explist) type [ exp 1 ray delete destroy delete pointer delete [] destroy array delete [] pointer (type) cast (type conversion) (type) exp.* member selection classobject * ptrtomember ->* member selection classobjectptr - > * ptrtomember * multiplication exp * exp / division exp / exp % modulo (remainder) exp%exp + addition exp + exp - subtraction exp - exp «shift left, stream output exp«exp» shift right, stream input exp» exp < less than exp < exp <= less than or equal to exp <= exp > greater than exp > exp >= greater than or equal to exp >= exp -- equal to exp == exp!= not equal to exp! = exp & bitwise and exp & exp A bitwise xor exp A exp I bitwise or exp I exp && logical and exp && exp II logical or exp I I exp = assign lvalue = exp *= multiply and assign lvalue * = exp /= divide and assign lvalue / = exp %= modulo and assign lvalue %= exp += add and assign lvalue + = exp -= subtract and assign lvalue - = exp «= shift left and assign lvalue «= exp»= shift right and assign lvalue»= exp &= bitwise "and" and assign lvalue &= exp 1= bitwise "or" and assign lvalue I = exp = bitwise "xor" and assign lvalue = exp A? conditional expression exp?exp: exp throw throw expression throwexp I sequence expression exp, exp Table A.I: Precedence, in decreasing order, of operators.

3 AppendixB The String Class The string class is actually an instance of the more general basic_string class template which takes three template arguments. The CharT type specifies the underlying type of character; a basic_string represents a sequence of such CharT objects. The Trai t s type specifies a number of properties of the CharT type, e.g. the "end of string" character, CharT comparison and conversion operations, etc. The Alloc parameter specifies a class that provides memory management services for the allocation of basic_string objects. For the string class, the parameters are instantiated as shown below. typedef basic_string<char,chaltraits<char>,allocator<char> > string; typedef basic_string<wchar_t,char_traits<wchar_t>,allocator<wchar_t> > wstring; The allocator<char> type is an instance of the standard system-provided allocator class template (see e.g. [Str97], page 567). Wstring is the equivalent of string for "wide" characters (see Section 2.1). tempiate<typename CharT, typename Traits, typename Alloc> class basic_string { public: typedef Traits traits-type; typedef typename Traits::char_type value_type; typedef Alloc allocatoltype; typedef typename Alloc::size_type size_type; II size of string type static const size_type npos = static_cast<size_type>c-1); II maximum size of a string typedef typename Alloc::difference_type difference_type; typedef typename Alloc::reference reference; typedef typename AlJoc::consLreference conslreference; typedef typename Alloc::pointer pointer; typedef typename AlJoc::consLpointer conslpointer; 267

4 268 APPENDIX B. THE STRING CLASS / / defining iterator types makes a string a container to which stl algorithms can be applied typedef... iterator; typedef... consliterator; typedef... conslreverse_iterator; typedef... reverse_iterator; / / construction, destruction, assignment inline basic_stringo; explicit basilstring(const AlIoc&); / / new string contains s{pos].. s{max(pos+n,size()-l)] basic_string(const basic_string& s, size_type pos=o, size_type n=npos, const AlIoc& a=alioc()); / / new string contains s{o].. s{n-l] basic_string(const CharT* s, size_type n, const AlIoc& a = AlIoc()); / / new string contains s{o].. s[strlen(s)-l] basic_string(const CharT* s, const AlIoc& a = AlIoc()); / / new string consists of n copies of c basic_string(size_type n, CharT c, const AlIoc& a = AlIoc()); / / Inputlterator::valuLtype should be CharT template< class Inputlterator> basic_string(inputiterator begin, Inputlterator end, const AlIoc& a = AlIoc()); oasic_stringo; basic_string& operator=(const basic_string& str); basilstring& operator=(const CharT* s); basic_string& operator=(chart c); / / e.g. s = 'a' makes a string of size 1 / / iterators iterator begin(); consliterator begino const; iterator endo; consliterator endo const; reverse_iterator rbegino; conslreverse_iterator rbegino const; reverse_iterator rendo; conslreverse_iterator rendo const; / / size of string size_type sizeo const; size_type lengtho const { return sizeo; } size_type max_sizeo const; / / max size of string, depends on allocator void resize(size_type n, CharT c=chart()); / / resize to n by erasing at end or appending c's size_type capacityo const; / / available size without reallocation void reserve(size_type n = 0); / / ensure n <= capacity() void clearo { resize(o); } bool emptyo const { return sizeo == 0; } / / element access conslreference operator[] (size_type position) const; reference operator[ ](size_type position); conslreference at(size_type position) const; / / throw oulof-,ange exception if out of range reference at(size_type position); / / append basic_string& operator+=(const basic_string& str) { return append(str); } basic_string& operator+=(const CharT* s) { return append(s); } basic_string& operator+=(chart c) { return append(1,c); } basic_string& append(const basilstring& s); basic_string& append(const basic_string& s, size_type pos, size_type n); / / append sipos].. s{pos+n-l] basic_string& append(const CharT* s, size_type n); / / append s[o]..s{n-l] basic_string& append( const CharT * s); basic_string& append(size_type n, CharT c); / / append n c's template<class Inputlterator> / / value_type should be CharT

5 APPENDIX B. THE STRING CLASS 269 basic_string& append(inputlterator first, Inputlterator last); void push_back(chart c); II *this += c II assign basic_string& assign(const basic_string& s); basic_string& assign(const basic_string& s, size_type pos, size_type n); II assign s[posj.. s[pos+n-lj basic_string& assign(const CharT* s, size_type n); II assign s[oj.. s[n-l] basicstring& assign(const CharT* s); basic_string& assign(size_type n, CharT c); II assign c.. c (n c's) template<c1ass Inputlterator> basic_string& assign(inputiterator first, Inputlterator last); II replace *(this[posj.. this[pos+n-l]) by.. basic_string& replace(size_type pos, size_type n, const basic_string& s); II s basicstring& replace(size_ type pos, size_type n, const basic_string& s, size_type p2, size_type n2); II s[p2j..s[p2+n2-l] basic_string& replace(size_ type pos, size_type n, const CharT* s, size_type n2); II s[oj..s[n2-l] basic_string& replace(size_type pos, size_type n, const CharT* s); II s basic_string& replace(size_type pos, size_type n, size_type n2, CharT c); II n2 c's template<c1ass InputIterator> II replace *il.. *i2 by *j1.. *j2 basic_string& replace(iterator ii, iterator i2, InputIterator jl, InputIterator j2); basicstring& replace(iterator ii, iterator i2, const basic_string& s) { return replace(i I,i2,s.beginO,s.end()); } basic_string& replace(iterator ii, iterator i2, const CharT* s, size_type n) { return replace(i I,i2,s,s+n); } basic_string& replace(iterator ii, iterator i2, const CharT* s) { return replace(ii,i2,s,s+traitltype::length(s»; } basic_string& replace(iterator ii, iterator i2, size_type n, CharT c); II replace *il.. *i2 by n c's II insert void insert(iterator p, size_type n, CharT c) { replace(p, p, n, c); } template< class Inputlterator> void insert(iterator p, Inputlterator beg, Inputlterator end) { replace(p,p,beg,end); } basic_string& insert(size_type pos, const basic_string& s) { replace(begino+pos, begin()+pos, s.begino, s.endo); return *this; } basic_string& insert(size_type posl, const basic_string& s, size_type pos2, size_type n); basicstring& insert(size_type pos, const CharT* s, size_type n); basic_string& insert(size_type pos, const CharT* s); basicstring& insert(size_type pos, size_type n, CharT c); iterator insert(iterator p, CharT c = CharT()); II erase basic_string& erase(size_type pos = 0, size_type n = npos); iterator erase(iterator position); iterator erase(iterator first, iterator last); II retrieving a C string const CharT* cstro const; const CharT* datao const; II result may NOT be a C string II searching strings, return matching position or string: :npos if not found size_type find(const CharT* s, size_type pos, size_type n) const; size_type find(const basic_string& s, size_type pos = 0) const; size_type find(const CharT* s, size_type pos = 0) const; size_type find(chart c, size_type pos = 0) const; size_type rfind(const basicstring& s, size_type pos = npos) const; size_type rfind(const CharT* s, size_type pos, size_type n) const; size_type rfind(const CharT* s, size_type pos = npos) const; size_type rfind(chart c, size_type pos = npos) const;

6 270 APPENDIX B. THE STRING CLASS size_type find_firslof(const basic_string& str, size_type pos = 0) const; size_type find_firslof(const CharT* s, size_type pos, size_type n) const; size_type find_firslof(const CharT* s, size_type pos = 0) const; size_type find_firslof(chart c, size_type pos = 0) const; size_type find_laslof(const basic_string& s, size_type pos = npos) const; size_type find_laslof(const CharT* s, size_type pos, size_type n) const; size_type find_laslof(const CharT* s, size_type pos = npos) const; size_type find_laslof(chart c, size_type pos = npos) const; size_type find_firslnolof(const basic_string& s, size_type pos = 0) const; size_type find_firslnolof(const CharT* s, size_type pos, size_type n) const; size_type find_firslnolof(const CharT* s, size_type pos = 0) const; size_type find_firslnolof(chart c, size_type pos = 0) const; size_type find_laslnolof(const basic_string& str, size_type pos = npos) const; size_type find_laslnolof(const CharT* s, size_type pos, size_type n) const; size_type find_laslnolof(const CharT* s, size_type pos = npos) const; size_type find_laslnolof(chart c, size_type pos = npos) const; / / grab substring basic_string substr(size_type pos = 0, size_type n = npos) const; / / compare (lexicographic): compare(sl,s2»0 is sl>s2, <0 if sl<s2, ==0 else int compare(const basic_string& s) const; int compare(size_type pos, size_type n, const basilstring& s) const; int compare(size_type posl, size_type nl, const basic_string& s, size_type pos2, size_type n2) const; int comparee const CharT * s) const; int compare(size_type pos, size_type nl, const CharT* s, size_type n2 = npos) const; }; / / ordinary string functions / / operator+: concatenate intine basic_string<ch,tr,a> operator+(const basic_string<ch,tr,a>& Is, const basic_string<ch,tr,a>& rs); intine basilstring<ch,tr,a> operator+(const Ch* Is, const basic_string<ch,tr,a>& rs); inline basic_string<ch,tr,a> operator+(ch Is, const basic_string<ch,tr,a>& rs); intine basic_string<ch,tr,a> operator+(const basic_string<ch,tr,a>& Is, const Ch* rs); intine basic_string<ch,tr,a> operator+(const basic_string<ch,tr,a>& Is, Ch rs); / / operator = = intine boot operator==(const basic_string<ch,tr,a>& Is, const basic_string<ch,tr,a>& rs); intine boot operator==(const Ch* Is, const basic_string<ch,tr,a>& rs); intine boot operator==(const basic_string<ch,tr,a>& Is, const Ch* rs); / / operator!= inline boot operator!=(const basic_string<ch,tr,a>& Is, const basic_string<ch,tr,a>& rs); intine boot operator!=(const Ch* Is, const basic_string<ch,tr,a>& rs); inline boot operator!=(const basilstring<ch,tr,a>& Is, const Ch* rs); / / operator < intine boot operator«const basic_string<ch,tr,a>& Is, const basic_string<ch,tr,a>& rs);

7 APPENDIX B. THE STRING CLASS 271 inune bool operator«const basic_string<ch,tr,a>& Is, const Ch* rs); inune bool operator«const Ch* Is, const basic_string<ch,tr,a>& rs); / / operator > inune bool operator>(const basic_string<ch,tr,a>& Is, const basic_string<ch,tr,a>& rs); inune bool operator>(const basic_string<ch,tr,a>& Is, const Ch* rs); inune bool operator>(const Ch* Is, const basicstring<ch,tr,a>& rs); / / operator < = inune bool operator<=(const basicstring<ch,tr,a>& Is, const basic_string<ch,tr,a>& rs); inune bool operator<=(const basic_string<ch,tr,a>& Is, const Ch* rs); inune bool operator<=(const Ch* Is, const basic_string<ch,tr,a>& rs); / / operator > = inune bool operator>=(const basic_string<ch,tr,a>& Is, const basic_string<ch,tr,a>& rs); inune bool operator>=(const basic_string<ch,tr,a>& Is, const Ch* rs); inune bool operator>=(const Ch* Is, const basicstring<ch,tr,a>& rs); / / I/O basic_istream<ch,tr>& / / read a string, skipping white space operator> >(basic_istream<ch,tr>& is, basic_string<ch,tr,a>& s); basic_ostream<ch,tr>& operator< «basic_ostream<ch,tr>& os, const basic_string<ch,tr,a>& s); basic_istream<ch,tr> & getline(basic_istream<ch,tr>& is, basic_string<ch,tr,a>& str, Ch delim); inune basic_istream<ch,tr>& getline(basic_istream<ch,tr>& is, basic_string<ch,tr,a>& s);

8 Bibliography [Aus98] Matthew H. Austem. Generic Programming and the STL. Addison Wesley, [CHW98] J. Coplien, D. Hoffman, and D. Weiss. On commonality and variability in software engineering. IEEE Software, 15(6):37-45, NovemberlDecember [Cop99] J. Coplien. Multi-Paradigm Designfor C++. Addison-Wesley, [GHJV94] E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, [LL98] [Str97] Stanley B. Lippman and Josee Lajoie. C++ primer. Addison-Wesley,3rd edition, Bjame Stroustrup. The C++ Programming Language. Addison-Wesley, 3rd edition, [WBW89] R. Wirfs-Brock and B. Wilkerson. Object-oriented design: A responsibility-driven approach. Proceedings OOPSLA '89, ACM SIG PLAN Notices, 24(10):71-76, October

9 Index " 65.cc,12.cpp,12 #define, 14 #endif, 15 #ifdef,15 #ifndef,15 #include, _,77 \',26 \\,26 \a,26 \b,26 \f, 26 \n,26 \r,26 \t,26 \v,26 (), 65,265,266,,43,266.C,12?, 44, 266 [], 65,265 &,89,266 &&,30,33,65,266 ->*,65,266 ->,65,115,265 &=,31,33,65,266 /=,31,33,65,266 -=,31,33,65,266 *=,31,33,65,266 1=,31,33,65,266 +=,31,33,65,266 %=,31,33,65,266 «=,31,33,65,266»=,31,33,65,266 ~=,31,33,65,266 =,31,33,65,266 &,29,33,65,266 -,29,33,65,68,266 1, 29, 33, 65, ,31,33,65,66,142,265,266 /,29,33,65,266.,265 ==,29,33,65,266 >=,29,33,65,266 >,29,33,65,266 ++,31,33,65,66,142,265,266 <=,29,33,65,266 <,29,33,65,266 -,29,33,65,266!=,29,33,65,266!,30,33,65,266 11,30,33,65,266 +,29,33,65,266 %,29,33,65,266 ::,265 «,29,33,65,227,229,266»,29,33,65,230,231,266.*,266 *,29,33,65,115,266 ~,29,33,65,266 *,34?,40 abstract class, 191 abstract data type, 2, 51 abstraction, 6, 52, 246 criteria, 252 instance, 250 sources, 252 access specifier, 53, 127, 194,247 private, 53, 67 protected, 53,

10 276 INDEX public, 53 accumulate, 173, 254 adaptor, 153, 163, 178 for container, 163, 177, 195 for iterator, 179 reversejterator, 181 address, 1, 89 adjacenldifference, 173 adjacentjind, 165 ADT,51 advance, 148 algorithm, 119, 164 copy, 152 copying, 169 counting, 166 filling, 170 find, 165 finding subranges, 165 heap operations, 177 maximum, 168 minimum, 168 mutating, 169 non-mutating, 165 numeric, 173 partitioning, 172 permuting, 171 processing a range, 166 random sampling, 172 random shuffling, 172 range comparison, 167 range transformation, 169 removing elements, 170 replacing, 169 set operations, 176 sort, 174 sorted range operations, 175 swapping, 169 allocator, 267 and bitwise, 29 logical, 29, 30 architecture, 246 argument deduction, 120 arguments default,38 unspecified, 38 arithmetic type, 25, 27 conversion, 27 operation, 28 operator, 29 array, 32, 95 and inheritance, 187 assignment, 97 initialization, 97 multidimensional, 101 parameter, 99 template class, 124 vs. pointer, 98 ASCII,26 asm, 19 assert.h, 77 assignment and conversion, 28 and initialization, 83 compound, 31 operator, 4,31,65, 110 statement, 4 associative container, 152, 157, 163 auto, 19 auto_ptr, 134 automatic object, 104 backjnsertjterator, 179, 180 backjnserter, 179 bad_cast, 202, 214 bad_exception, 214 bad_typeid, 214 base class, 183 base object, 184 basic_filebuf, 234 basicjstream, 236 basicjfstream, 235 basicjos, 226 basicjostream, 218, 231 basicjstream, 218, 227 basicjstringstream, 237 basic_ofstream, 236 basic_ostream, 218, 230 basic_ostringstream, 237 basic_streambuf, 218, 220 basic_string, 267

11 INDEX 277 bidirectional iterator, 142 bidirectionauterator _tag, 145 binary...search, 175 bitwise and, 29 bitwise complement operator, 29 bitwise or, 29 bitwise xor, 29 bool, 19,26 conversion to, 28 literal,26 boolalpha, 232 boolean, 26 break,19 break statement, 48 built-in types, 25 C,187 C string, 32 call by address, 11, 92 by reference, 10, 68, 84 by value, 10, 30, 83, 208 destructor, 212 frame, 49 function, 7, 43, 104,265 inline,40 late binding, 188 operator, 130 overloaded, 41 result, 8 retum,47 target, 56, 75 main function, 17 stack, 9,49, 104,208 case, 19 in switch statement, 46 sensitive, 19 use, 259 cast bad, 202,214 C style, 32, 266 const, 19,88,94,265 cross, 201 down, 201 dynamic, 19,201,203,265 static, 19, 112, 138,235,236,265 up, 201 catch, 19, 206 cccp,14 char, 19, 26, 34 character zero, 32 class, 19,51,53 abstract, 191 base, 183 virtual, 195,219 constructor, 56 copy, 58 default, 58 derived, 183 constructor, 185 destructor, 68 friend,73 hierarchy, 199 member, 53 object, 69 static,74 virtual, 187 member function constant, 86 nested,72 object, 54 member, 69 polymorphic, 202 scope, 55 template, 123, 124 instance, 125 specialization, 131 virtual member function, 188 class object, 5 life, 71 class template, 123 friends, 126 nested,127 code object, 14 cohesion, 255 data, 255 functional, 255 temporal, 256 collaborator, 259 command line, 101

12 278 INDEX comments, 20 commonalities, 250 compilation, 13 compiler, 12 complex, 103 component, 247 composition, 258 compound assignment, 31 compound statement, 43 const, 19,34,83 conslcast, 19,88,94,265 constant expression, 46 member function, 86 name, 20 pointer, 92 constants, 2 constness logical,88 physical, 88 constructor, 32, 56, 59, 105 copy,58,66,110 default, 58, 84, 106 derived class, 185 explicit, 62 value, 32, 81 container, 152 adaptor, 153, 177 associative, 152 deque, 163 hash-iilap, 163 hash-iiluitimap, 163 hash-iilultiset, 163 hash_set, 163 list, 153 map, 157 multimap, 163 multiset, 163 sequence, 152 set, 161 slist, 163 vector, 155 container adaptor, 163 continue, 19 continue statement, 48 control coupling, 257 control flow, 43 statement, 43 conversion, 27, 42, 61 and inheritance, 186 and overloading, 42 arithmetic type, 27 array to pointer, 98 explicit, 62 function, 61 of 0 to pointer, 90 of an arithmetic expression, 28 to boo!, 28 to void*, 111 copy, 152, 169 copy algorithm, 152 copy constructor, 58, 66, 110 copy_backward, 169 count, 166 counuf,166 coupling, 256 control, 257 derived class, 258 global object, 257 parameter, 257 representational, 256 cpp, 14 CRC, 259 criteria for abstraction, 252 crosscast, 201 cstdarg,39 cstr2double, 245 cvs, 20 dangling pointer, 106 data abstraction, 247 data cohesion, 255 data member, 53, 54 static,74 data object, 1 dec, 232 declaration, 12 and definition, 12 constructor, 56 data member, 54 destructor, 68

13 INDEX 279 friend, 126, 150 function, 12,29,37,58,213 candidate, 42 function member, 55 header file, main function, 101 member, 53 mutable, 88 parameter, 7 scope, 23 statement, 43 static data member, 74 syntax, 12 template parameter, 118 translation unit, 19 typedef,81 using, 23 variable, 12, 102 without definition, 67 decrement, 31, 33, 66,141,142,265 default,19 default arguments, 38 default constructor, 58, 106 default value, 32 definition, 12 class, 53 class object, 54 class template, 123 function, 6, 42 function template, 117 namespace, 22 object, 3 of ADTs, 53, 163 reference variable, 4 symbol,17 type, 15 variable, 3 delete, 19,65, 105, 106,266 overloading, 110, 113 delete[], 106, 110 denominator, 54 dependency, 247 inheritance, 248 interface, 248 deque, 163, 164 dereference, 90 derivation, 183 private, 259 derived class coupling, 258 design classes, 260 pattern, 261 process, 259 destructor, 68, 110 and exceptions, 212 call,212 derived class, 185 virtual, 192 difference_type, 146, 147 directive #define, 14 #endif,15 #ifdef,15 #ifndef,15 #include, 14 preprocessor, 14 using, 24 do, 19 documentation, 260 domain classes, 259 domain_error, 215 double, 3, 19,25 downcast, 201 dynamic_cast, 19,201,203,265 else, 19 encapsulation, 51, 52, 247 of pointer, 107 endl,233 ends, 233 enum,19 enumeration type, 32, 68, 80, 132, 223 environment, 8 equal,167 equalrange, 175 exception, 48,206,214 bad cast, 202, 214 exception handling, 205, 206 executable file, 17 exit, 39 explicit, 19,62

14 280 INDEX conversion, 62 export, 15 expression, 2, 3 constant, 46 function call, 7 new, 105 statement, 42 extendible, 243 extern, 19 factory method, 133, 185 false, 19,26 family, 243 file executable, 17 object, l3 filebuf, 234 fill,170 fill-il, 170 finalizing an object, 68 find, 165 find_end, 165 find_firslof, 165 findj.f, 165 first, 153 fixed,232 float, 19,26 floating point number, 25 flush,233 for, 19 for statement, 45 foleach, 166 formal parameter, 7 reference, 10 format flags, 223 forward iterator, 142 forwardj.terator_tag, 145 fprintf,39 frame, 9 framework, 222 free object, 105 friend, 19, 71, 73 of class template, 126 fronunsertj.terator, 180 fronunserter, 180 fstream, 235, 236 function, 6, 12 body, 7 call,7,43 result, 8, 48 constructor, 56 declaration, 12, 37 candidate, 42 default arguments, 38, 61 definition, 6, 7, 42 body, 42 scope, 21 inline, 40, 60 main, 101 member, 53, 55, 59 declaration, 55 overloading, 56 name, 20 object, 128, l30, 131, 166, 233, 254 overloading, 41 pointer to, 102 polymorphic, 200 pure virtual member, 191 signature, 37 template, 117, 118, 203, 248, 250 argument deduction, 120 overloading, 120, 148 specialization, 120, 122 type, 37 unspecified arguments, 38 virtual member, 187 implementation, 189 functional, l31 functional abstraction, 246 functional cohesion, 255 generate, 170 generatejl, 170 generic programming, 140 getline, 229, 267 global object, 104 global object coupling, 257 good programs, 241 goto, 19,48 handle, 91

15 INDEX 281 has-a, 258 hash-illap, 163 hash-illu1timap, 163 hash-illultiset, 163 hash_set, 163 header file, 15,247 heap, 105, 177 hex, 232 identifier, 19 if,19 operator, 40 statement, 9, 43 ifstream, 235 implementation, 51, 246 multiple inheritance, 196 virtual member function, 189 includes, 176 increment, 31,66,141,142,265 inheritance, 184 access control, 193 and arrays, 187 and conversion, 186 and scope, 185 dependency, 248 multiple, 195 polymorphism, 199 private, 194, 259 protected, 194 virtual, 195, 197,219 initialization, 3 of array, 97 vs. assignment, 83 inline, 19 inline function, 40, 60 innelproduct, 173 inplace-illerge, 175 input iterator, 142 inputiterator _tag, 145 instantiation of abstraction, 250 template, int, 2, 19,25,27 integer hexadecimal constant, 25 literal, 25 octal constant, 25 type, 26 integral type, 27, 46 interface, 51, 246 interface dependency, 248 internal, 232 invalid...argument, 215 ios, 226 ios_base, 224 ios_base.h,232 iostream, 217, 231 library, 30, 34 is-a, 183, 199,258 islleap, 177 is_sorted, 174 istream, 227 istreamiterator, 149 istringstream, 237 iterator, 115, 140, 141, 145, 146 adaptor, 178, 179 bidirectional, 142 category, 148 forward, 142 input, 142 input stream, 149 insert, 178 istream, 149 ostream, 152 output, 142 output stream, 151 random access, 142 reverse, 181 stream, 149 traits, 146 types associated with, 143 iteratolcategory, 146, 147 iterator _traits, 147 itoa, 238 Java, 89, 185, 192 keyword, 19 late binding, 188, 189 left, 232 length_error, 215

16 282 INDEX lexicographicalcompare, 167 overloading, 56 library, 247 pure virtual, 191 C++ standard, 24 virtual, 188 iostream, 30, 34 object, 69, 105 life of a class object, 71 pointer, 103, 107,233 linker, 17 protected, 193 symbol,17 pure virtual, 191 list, 153, 164 selection, 91 literal static,74 bool,26 virtual, 187 constant, 25 memory, 134 hexadecimal integer, 25 leak,107 integer, 25 management, 104 octal integer, 25 merge, 175 string, 32 message, 56 local object, 49 min, 168 lifetime, 49 min_element, 168 local variable, 49 mismatch,167 static,49 mixin, 196 logic_error, 215, 216 module, 247 logical and, 29, 30 multidimensional array, 101 logical not, 30 multimap, 163 logical or, 30 multiple inheritance, 195 long, 19,25 implementation, 196 double, 25 multiset, weLbound, 175 mutable, 19,88 lvalue, 3, 65, 89, 265 returned by function, 11 namespace, 19,22 naming convention, 19 macro, 39 negative variability, 250 main function, 17, 101 nested class, 72 maintainability, 243 nested class template, 127 makelleap, 177 new, 19,65,68, 113,266 mangle, 75 overloading, 110, 113 manipulator, 225, 232 placement, 113 map, 157, 158,258 new operator, 105 max, 168 new[], 105, 110 max-element, 168 nexlpermutation, 171 memjun, 166, 167 noboolalpha, 232 memjunjef, 167 noshowbase, 232 member noshowpoint, 232 access, 53 noshowpos, 232 data, 53, 54 noskipws, 232 declaration, 53 not function, 53, 55, 59 logical,30 declaration, 55 nounitbuf,232

17 INDEX 283 nouppercase, 232 nth_element, 174 null pointer, 90, 93, 106 number floating point, 25 numerator, 54 numeric, 164, 173 object, 1 address, 89 automatic, 104 class, 5, 54, 56 code, 14, 18 constant, 83 data, 1 definition, 3 deletion, 106 finalization, 68 free, 105 function, 128, 130,233 global,104 initialization, 56 layout, 54 member, 105 owner, 105 persistence, 202 static, 104 object file, 13, 17,247 object-oriented programming, 199 observable, 261 observer, 261 observer pattern, 261 oct, 232 of stream, 236 operator, 19,28 " 43 ::,60?,40,44 =,65 --, , 142 «0,229 «,227»,230,231 address of, 89 assignment, 4,31,65,110 bitwise and, 29 bitwise complement, 29 bitwise or, 29 bitwise xor, 29 decrement, 31 delete, 106 delete[], 106 forbidding, 67 function, 29, 63 if, 40, 44 increment, 31 logical and, 30 logical not, 30 logical or, 30 new, 105 on arithmetic type, 29 overloading, 29,63 precedence, 32,265 scope, 49, 60 scope resolution, 73 sequence, 43 shift left, 29 shift right, 29 static_cast, 112, 138 value constructor, 32,81 or bitwise, 29 logical,30 ordering strictly weak:, 174 ostream, 42,230 ostreamjterator, 151, 152 ostringstream, 192,237 oulolrange, 215 output stream, 30 output iterator, 142 outpuuterator_tag, 145 overflow, 218 overflow_error, 215 overloaded,30 overloading, 38, 41 ->, 115 =,65 --,66

18 284 INDEX ++,66 *, 115 delete, 11 0, 113 function template, 120 matching rules, 42 member function, 56 new, 110, 113 operator, 63 resolution, 121 override, 252 overriding, 185 owner object, 105 ownership of pointer, 134 pair, 153 parameter, 6 array, 99 control, 257 conversion, 61 coupling, 257 declaration, 7 default value, 38, 61 formal,7 reference, 10 of main function, 10 1 placement new, 114 reference, 83 template, 118, 131 type, 37,117 parametrized type, 125 partial specialization, 131 partialsort, 174 partialsort_copy, 174 partialsum, 173 partition, 172 pattern, 261 persistent objects, 202 placement new, 113, 114 pointer, 34, 89, 146, 147 arithmetic, 98 constant, 92 dereference, 90 difference_type, 147 encapsulation, 107 iteratolcategory, 147 iteratoltraits, 147 member, 103, 107 null,90,93,106 pointer, 147 reference, 147 smart, 115 this, 93 to function, 102 to member, 103, 233 to pointer, 91 value_type, 147 vs. array, 98 vs. reference, 92 polymorphic class, 202 function, 200 polymorphism, 117, 118, 199 poplleap, 177 precedence, 32, 265 precision, 224 preprocessor, 14 directive, 14 prev _permutation, 171 priority queue, 177 priority _queue, 163 private, 19,53, 183, 186 inheritance, 194 problem space, 252 program linking, 17 organization, 15 structure, 12 program specification, 241 programming generic, 137 object-oriented, 199 promotion, 28 protected, 19,53, 193 inheritance, 194 public, 19,53 pure virtual member function, 191 pushlleap, 177 queue, 163 priority, 177 quicksort, 122

19 INDEX 285 random access iterator, 142 random-'lccessjterator _tag, 145 random-sample, 172 random_shuffle, 172 range_error, 215 Rational, 76 red-black tree, 158, 161 refactoring, 260 reference, 146, 147 counting, 132 type, 4, 12,83 variable, 4 vs. pointer, 92 register, 19 reinterprelcast, 19, 265 relocate, 18 remove, 170 remove_copy, 170 remove_copy jf, 170 removejf, 170 replace, 169 replace_copy, 169 replace_copy jf, 169 replaceif, 169 representational coupling, 256 resolve, 17 return, 19 return statement, 7, 47 reverse, 171 reverse_copy, 171 reversejterator, 181, 182 right, 232 robust program, 241, 242 rotate, 171 rotate_copy, 171 rtti,201 run-time type identification, 201 runtime_error, 215 rvalue,3 scientific, 232 scope, 21 and inheritance, 185 class, 55 defined by compound statement, 43 function body, 42 nested,21 operator, 49, 60 resolution, 23, 55 resolution operator, 73 search,165 searchjl, 165 second,153 segmentation fault, 242 selection of member, 91 sentinel, 100 sequence container, 152 services, 259 set, 161 seldifference, 176 setintersection, 176 selsymmetric_difference, 176 selunion, 176 shift left operator, 29 shift right operator, 29 short, 19,25,27 showbase, 232 showpoint, 232 showpos, 232 side effects, 37 signature, 37 signatures, 41 signed,19 size_t, 111 sizeof, 19,31,33,111,114,189,266 skipws, 232 slist, 163 smart pointer, 115 software maintenance, 243 solution space, 252 sort, 174 sortlleap, 177 source code control system, 20 source file, 12, 247 sparse matrix, 159 specialization, 252 class template, 131 function template, 120, 122 partial, 131, 147 specification, 241

20 286 INDEX sstream, 237 stable_partition, 172 stable_sort, 174 stack,163 standard library, 138 statement, 3, 7, 42 assignment, 4 break,48 compound, 43 continue, 48 control flow, 43 declaration, 43 expression, 42 for, 45 function call, 43 goto, 48 if, 9, 43 return, 7, 47 switch,46 while, 44 static, 19 local variable, 49 member, 74 object, 104 static_cast, 19, 112, 138,235,236 static_cast, 265 std,24 stdarg.h, 39 stddef.h, 111 stdlib.h, 79 stream output, 30 streambuf, 219, 220 streams, 217 strictly weak ordering, 174 string, 32, 267 literal, 32 string literal, 97, 100 struct, 19, 127 subclass, 183 substitutability, 183,258 subtype, 183 superclass, 183 swap, 169 swap..ranges, 169 switch,19 switch statement, 46 symbol linker, 17 unresolved, 17 tab character, 38 target of a member function call, 56, 60 template, 2, 19, 117 class, 123, 124 friends, 126 nested, 127 partial specialization, 131 specialization, 131 function, 117, 118,248,250 argument deduction, 120 overloading, 120 specialization, 120, 122 instance, 119 instantiation, parameter, 118 type parameter, 118 temporal cohesion, 256 terminate, 209, 212 this, 19,66,93 throw, 19,206,266 tied streams, 226 tilde, 68 traits, 146 iterator, 147 transform, 169, 254 translation unit, 12, 19 true, 19,26 try,19,206 try statement, 206 type, 2,12 ADT,51 arithmetic, 25, 27 conversion, 27 operator, 28 associated with iterator, 143 built-in, 25 constant, 83 constructor, 83 default value, 32

21 INDEX 287 enumeration, 32, 68, 80 integer, 26 integral, 27, 46, 80 name, 19 offunction,37 pointer member, 103 reference, 4 type constructor, 2, 83, 117 reference, 5 typedef, 19,81 typeid, 19,201,203,265 typeinfo, 201 typename, 19, 118, 145 UML,260 uncaught...exception, 213 underflow, 218 underflow_error, 215 underscore, 77 unicode, 26 union, 19 unique, 170 unique_copy, 170 unitbuf, 232 unresolved symbol, 17 unsigned, 19, 26 unsigned int, 26, 27 unsigned long, 26 unsigned short, 26, 27 unspecified number of arguments, 38 upcast, 201 uppelbound, 175 uppercase, 232 URL,258 use case, 259 user-defined conversion, 61 using, 19 declaration, 23 directive, 24 value, 2 constructor, 32, 105 default,32 value_type, 146, 147 variability, 250 negative, 250 variable, 2, 3, 12 declaration, 12 local,49 name, 20 reference, 4 static,49 vector, 101, 152, 155, 156, 164 virtual, 19, 188 base class, 198,219 destructor, 192 function table, 189 inheritance, 195, 197,219 member function, 188 void,7,19 void*, 111 volatile, 19 vptr, 189,202 vtbl,189 wchalt, 19, 26 wfilebuf, 234 wfstream, 236 while, 19 statement, 44 white space, 151,224 wide character, 26 width,224 wifstream, 235 wios, 226 wiostream, 231 wistream, 227 wistringstream, 237 wofstream, 236 wostream, 230 wostringstream, 237 wstreambuf, 220 wstring, 267 xor bitwise, 29 zero character, 32

Contents. 2 Introduction to C++ Programming,

Contents. 2 Introduction to C++ Programming, cppfp2_toc.fm Page vii Thursday, February 14, 2013 9:33 AM Chapter 24 and Appendices F K are PDF documents posted online at www.informit.com/title/9780133439854 Preface xix 1 Introduction 1 1.1 Introduction

More information

Absolute C++ Walter Savitch

Absolute C++ Walter Savitch Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents

More information

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object CHAPTER 1 Introduction to Computers and Programming 1 1.1 Why Program? 1 1.2 Computer Systems: Hardware and Software 2 1.3 Programs and Programming Languages 8 1.4 What is a Program Made of? 14 1.5 Input,

More information

Deitel Series Page How To Program Series

Deitel Series Page How To Program Series Deitel Series Page How To Program Series Android How to Program C How to Program, 7/E C++ How to Program, 9/E C++ How to Program, Late Objects Version, 7/E Java How to Program, 9/E Java How to Program,

More information

The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured

The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured Introduction p. xxix The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured Language p. 6 C Is a Programmer's Language

More information

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things. A Appendix Grammar There is no worse danger for a teacher than to teach words instead of things. Marc Block Introduction keywords lexical conventions programs expressions statements declarations declarators

More information

Chapter 15 - C++ As A "Better C"

Chapter 15 - C++ As A Better C Chapter 15 - C++ As A "Better C" Outline 15.1 Introduction 15.2 C++ 15.3 A Simple Program: Adding Two Integers 15.4 C++ Standard Library 15.5 Header Files 15.6 Inline Functions 15.7 References and Reference

More information

Preface to the Second Edition Preface to the First Edition Brief Contents Introduction to C++ p. 1 A Review of Structures p.

Preface to the Second Edition Preface to the First Edition Brief Contents Introduction to C++ p. 1 A Review of Structures p. Preface to the Second Edition p. iii Preface to the First Edition p. vi Brief Contents p. ix Introduction to C++ p. 1 A Review of Structures p. 1 The Need for Structures p. 1 Creating a New Data Type Using

More information

C++ How To Program 10 th Edition. Table of Contents

C++ How To Program 10 th Edition. Table of Contents C++ How To Program 10 th Edition Table of Contents Preface xxiii Before You Begin xxxix 1 Introduction to Computers and C++ 1 1.1 Introduction 1.2 Computers and the Internet in Industry and Research 1.3

More information

Borland 105, 278, 361, 1135 Bounded array Branch instruction 7 break statement 170 BTree 873 Building a project 117 Built in data types 126

Borland 105, 278, 361, 1135 Bounded array Branch instruction 7 break statement 170 BTree 873 Building a project 117 Built in data types 126 INDEX = (assignment operator) 130, 816 = 0 (as function definition) 827 == (equality test operator) 146! (logical NOT operator) 159!= (inequality test operator) 146 #define 140, 158 #include 100, 112,

More information

Tokens, Expressions and Control Structures

Tokens, Expressions and Control Structures 3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

Introduction to C++ Systems Programming

Introduction to C++ Systems Programming Introduction to C++ Systems Programming Introduction to C++ Syntax differences between C and C++ A Simple C++ Example C++ Input/Output C++ Libraries C++ Header Files Another Simple C++ Example Inline Functions

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

Chapters and Appendices F J are PDF documents posted online at the book s Companion Website, which is accessible from.

Chapters and Appendices F J are PDF documents posted online at the book s Companion Website, which is accessible from. Contents Chapters 23 26 and Appendices F J are PDF documents posted online at the book s Companion Website, which is accessible from http://www.pearsonhighered.com/deitel See the inside front cover for

More information

Lecture 21 Standard Template Library. A simple, but very limited, view of STL is the generality that using template functions provides.

Lecture 21 Standard Template Library. A simple, but very limited, view of STL is the generality that using template functions provides. Lecture 21 Standard Template Library STL: At a C++ standards meeting in 1994, the committee voted to adopt a proposal by Alex Stepanov of Hewlett-Packard Laboratories to include, as part of the standard

More information

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS Contents Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS 1.1. INTRODUCTION TO COMPUTERS... 1 1.2. HISTORY OF C & C++... 3 1.3. DESIGN, DEVELOPMENT AND EXECUTION OF A PROGRAM... 3 1.4 TESTING OF PROGRAMS...

More information

Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts

Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute C++, by Walter

More information

Problem Solving with C++

Problem Solving with C++ GLOBAL EDITION Problem Solving with C++ NINTH EDITION Walter Savitch Kendrick Mock Ninth Edition PROBLEM SOLVING with C++ Problem Solving with C++, Global Edition Cover Title Copyright Contents Chapter

More information

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and #include The Use of printf() and scanf() The Use of printf()

More information

Basic Types, Variables, Literals, Constants

Basic Types, Variables, Literals, Constants Basic Types, Variables, Literals, Constants What is in a Word? A byte is the basic addressable unit of memory in RAM Typically it is 8 bits (octet) But some machines had 7, or 9, or... A word is the basic

More information

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix PGJC4_JSE8_OCA.book Page ix Monday, June 20, 2016 2:31 PM Contents Figures Tables Examples Foreword Preface xix xxi xxiii xxvii xxix 1 Basics of Java Programming 1 1.1 Introduction 2 1.2 Classes 2 Declaring

More information

CS3157: Advanced Programming. Outline

CS3157: Advanced Programming. Outline CS3157: Advanced Programming Lecture #12 Apr 3 Shlomo Hershkop shlomo@cs.columbia.edu 1 Outline Intro CPP Boring stuff: Language basics: identifiers, data types, operators, type conversions, branching

More information

cs3157: c++ lecture #2 (mon-11-apr-2005) chronology of some programming languages... C++ vs Java identifiers.

cs3157: c++ lecture #2 (mon-11-apr-2005) chronology of some programming languages... C++ vs Java identifiers. cs3157: c++ lecture #2 (mon-11-apr-2005) chronology of some programming languages... today: language basics: identifiers, data types, operators, type conversions, branching and looping, program structure

More information

Variables. Data Types.

Variables. Data Types. Variables. Data Types. The usefulness of the "Hello World" programs shown in the previous section is quite questionable. We had to write several lines of code, compile them, and then execute the resulting

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Learning Objectives. C++ For Artists 2003 Rick Miller All Rights Reserved xli

Learning Objectives. C++ For Artists 2003 Rick Miller All Rights Reserved xli Identify and overcome the difficulties encountered by students when learning how to program List and explain the software development roles played by students List and explain the phases of the tight spiral

More information

University of Technology. Laser & Optoelectronics Engineering Department. C++ Lab.

University of Technology. Laser & Optoelectronics Engineering Department. C++ Lab. University of Technology Laser & Optoelectronics Engineering Department C++ Lab. Second week Variables Data Types. The usefulness of the "Hello World" programs shown in the previous section is quite questionable.

More information

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above P.G.TRB - COMPUTER SCIENCE Total Marks : 50 Time : 30 Minutes 1. C was primarily developed as a a)systems programming language b) general purpose language c) data processing language d) none of the above

More information

C++ Primer, Fifth Edition

C++ Primer, Fifth Edition C++ Primer, Fifth Edition Stanley B. Lippman Josée Lajoie Barbara E. Moo Upper Saddle River, NJ Boston Indianapolis San Francisco New York Toronto Montreal London Munich Paris Madrid Capetown Sidney Tokyo

More information

Welcome to Teach Yourself Acknowledgments Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p.

Welcome to Teach Yourself Acknowledgments Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p. Welcome to Teach Yourself p. viii Acknowledgments p. xv Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p. 6 Standard C++: A Programming Language and a Library p. 8

More information

Advanced C++ Programming Workshop (With C++11, C++14, C++17) & Design Patterns

Advanced C++ Programming Workshop (With C++11, C++14, C++17) & Design Patterns Advanced C++ Programming Workshop (With C++11, C++14, C++17) & Design Patterns This Advanced C++ Programming training course is a comprehensive course consists of three modules. A preliminary module reviews

More information

I BSc(IT) [ Batch] Semester II Core: Object Oriented Programming With C plus plus - 212A Multiple Choice Questions.

I BSc(IT) [ Batch] Semester II Core: Object Oriented Programming With C plus plus - 212A Multiple Choice Questions. Dr.G.R.Damodaran College of Science (Autonomous, affiliated to the Bharathiar University, recognized by the UGC)Reaccredited at the 'A' Grade Level by the NAAC and ISO 9001:2008 Certified CRISL rated 'A'

More information

Refinements to basic_string

Refinements to basic_string Doc. No.: X3J16/95-0028 WG21/N0628 Date: January 30, 1995 Project: Reply To: Programming Language C++ Richard K. Wilhelm Andersen Consulting rkw@chi.andersen.com Refinements to basic_string 1. Introduction

More information

Standard Library Reference

Standard Library Reference Standard Library Reference This reference shows the most useful classes and functions in the standard library. Note that the syntax [start, end) refers to a half-open iterator range from start to end,

More information

UNIT- 3 Introduction to C++

UNIT- 3 Introduction to C++ UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage

More information

Interview Questions of C++

Interview Questions of C++ Interview Questions of C++ Q-1 What is the full form of OOPS? Ans: Object Oriented Programming System. Q-2 What is a class? Ans: Class is a blue print which reflects the entities attributes and actions.

More information

C++ (Non for C Programmer) (BT307) 40 Hours

C++ (Non for C Programmer) (BT307) 40 Hours C++ (Non for C Programmer) (BT307) 40 Hours Overview C++ is undoubtedly one of the most widely used programming language for implementing object-oriented systems. The C++ language is based on the popular

More information

CS201 Some Important Definitions

CS201 Some Important Definitions CS201 Some Important Definitions For Viva Preparation 1. What is a program? A program is a precise sequence of steps to solve a particular problem. 2. What is a class? We write a C++ program using data

More information

Non-numeric types, boolean types, arithmetic. operators. Comp Sci 1570 Introduction to C++ Non-numeric types. const. Reserved words.

Non-numeric types, boolean types, arithmetic. operators. Comp Sci 1570 Introduction to C++ Non-numeric types. const. Reserved words. , ean, arithmetic s s on acters Comp Sci 1570 Introduction to C++ Outline s s on acters 1 2 3 4 s s on acters Outline s s on acters 1 2 3 4 s s on acters ASCII s s on acters ASCII s s on acters Type: acter

More information

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9 Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Uppercase Alphabets Lowercase Alphabets Character Set A, B, C, Y, Z a, b, c, y, z Digits

More information

Introduction to Programming

Introduction to Programming Introduction to Programming session 6 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Spring 2011 These slides are created using Deitel s slides Sharif University of Technology Outlines

More information

ME240 Computation for Mechanical Engineering. Lecture 4. C++ Data Types

ME240 Computation for Mechanical Engineering. Lecture 4. C++ Data Types ME240 Computation for Mechanical Engineering Lecture 4 C++ Data Types Introduction In this lecture we will learn some fundamental elements of C++: Introduction Data Types Identifiers Variables Constants

More information

Streams - Object input and output in C++

Streams - Object input and output in C++ Streams - Object input and output in C++ Dr. Donald Davendra Ph.D. Department of Computing Science, FEI VSB-TU Ostrava Dr. Donald Davendra Ph.D. (Department of Computing Streams - Object Science, input

More information

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites: C Programming Code: MBD101 Duration: 10 Hours Prerequisites: You are a computer science Professional/ graduate student You can execute Linux/UNIX commands You know how to use a text-editing tool You should

More information

Index COPYRIGHTED MATERIAL

Index COPYRIGHTED MATERIAL Index COPYRIGHTED MATERIAL Note to the Reader: Throughout this index boldfaced page numbers indicate primary discussions of a topic. Italicized page numbers indicate illustrations. A abstract classes

More information

Axivion Bauhaus Suite Technical Factsheet MISRA

Axivion Bauhaus Suite Technical Factsheet MISRA MISRA Contents 1. C... 2 1. Misra C 2004... 2 2. Misra C 2012 (including Amendment 1). 10 3. Misra C 2012 Directives... 18 2. C++... 19 4. Misra C++ 2008... 19 1 / 31 1. C 1. Misra C 2004 MISRA Rule Severity

More information

Jayaram college of Engineering and Technology, Pagalavadi. CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT

Jayaram college of Engineering and Technology, Pagalavadi. CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT Two Mark Questions UNIT - I 1. DEFINE ENCAPSULATION. Encapsulation is the process of combining data and functions

More information

C-LANGUAGE CURRICULAM

C-LANGUAGE CURRICULAM C-LANGUAGE CURRICULAM Duration: 2 Months. 1. Introducing C 1.1 History of C Origin Standardization C-Based Languages 1.2 Strengths and Weaknesses Of C Strengths Weaknesses Effective Use of C 2. C Fundamentals

More information

COEN244: Class & function templates

COEN244: Class & function templates COEN244: Class & function templates Aishy Amer Electrical & Computer Engineering Templates Function Templates Class Templates Outline Templates and inheritance Introduction to C++ Standard Template Library

More information

Practical C++ Programming

Practical C++ Programming SECOND EDITION Practical C++ Programming Steve Oualline O'REILLY' Beijing Cambridge Farnham Koln Paris Sebastopol Taipei Tokyo Preface xv Part I. The Basics 1. What Is C++? 3 A Brief History of C++ 3 C++

More information

4 Strings and Streams. Testing.

4 Strings and Streams. Testing. Strings and Streams. Testing. 21 4 Strings and Streams. Testing. Objective: to practice using the standard library string and stream classes. Read: Book: strings, streams, function templates, exceptions.

More information

JAYARAM COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli (An approved by AICTE and Affiliated to Anna University)

JAYARAM COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli (An approved by AICTE and Affiliated to Anna University) Estd: 1994 JAYARAM COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli - 621014 (An approved by AICTE and Affiliated to Anna University) ISO 9001:2000 Certified Subject Code & Name : CS 1202

More information

Harmonizing Effects and Returns Elements in Clause 21

Harmonizing Effects and Returns Elements in Clause 21 Harmonizing Effects and Returns Elements in Clause 21 Introduction Document number: N3021=10-0011 Date: 2010-02-10 Author: Martin Sebor Contact: msebor@gmail.com Organization: Cisco Systems, Inc. Library

More information

Contents. 1 Introduction to Computers, the Internet and the World Wide Web 1. 2 Introduction to C Programming 26

Contents. 1 Introduction to Computers, the Internet and the World Wide Web 1. 2 Introduction to C Programming 26 Preface xix 1 Introduction to Computers, the Internet and the World Wide Web 1 1.1 Introduction 2 1.2 What Is a Computer? 4 1.3 Computer Organization 4 1.4 Evolution of Operating Systems 5 1.5 Personal,

More information

by Pearson Education, Inc. All Rights Reserved. 2

by Pearson Education, Inc. All Rights Reserved. 2 Data that is formatted and written to a sequential file as shown in Section 17.4 cannot be modified without the risk of destroying other data in the file. For example, if the name White needs to be changed

More information

OBJECT ORIENTED PROGRAMMING USING C++

OBJECT ORIENTED PROGRAMMING USING C++ OBJECT ORIENTED PROGRAMMING USING C++ Overview of C++ Overloading Overloading occurs when the same operator or function name is used with different signatures Both operators and functions can be overloaded

More information

CERTIFICATE IN WEB PROGRAMMING

CERTIFICATE IN WEB PROGRAMMING COURSE DURATION: 6 MONTHS CONTENTS : CERTIFICATE IN WEB PROGRAMMING 1. PROGRAMMING IN C and C++ Language 2. HTML/CSS and JavaScript 3. PHP and MySQL 4. Project on Development of Web Application 1. PROGRAMMING

More information

Programming Fundamentals - A Modular Structured Approach using C++ By: Kenneth Leroy Busbee

Programming Fundamentals - A Modular Structured Approach using C++ By: Kenneth Leroy Busbee 1 0 1 0 Foundation Topics 1 0 Chapter 1 - Introduction to Programming 1 1 Systems Development Life Cycle N/A N/A N/A N/A N/A N/A 1-8 12-13 1 2 Bloodshed Dev-C++ 5 Compiler/IDE N/A N/A N/A N/A N/A N/A N/A

More information

Instantiation of Template class

Instantiation of Template class Class Templates Templates are like advanced macros. They are useful for building new classes that depend on already existing user defined classes or built-in types. Example: stack of int or stack of double

More information

EEE145 Computer Programming

EEE145 Computer Programming EEE145 Computer Programming Content of Topic 2 Extracted from cpp.gantep.edu.tr Topic 2 Dr. Ahmet BİNGÜL Department of Engineering Physics University of Gaziantep Modifications by Dr. Andrew BEDDALL Department

More information

Dodatak D Standardna string klasa

Dodatak D Standardna string klasa Dodatak D Standardna klasa from: C++ annotations, by Frank C. Brokken, University of Groningen, ISBN 90 367 0470. The C programming language offers rudimentary support: the ASCII-Z terminated series of

More information

Fundamentals of Programming

Fundamentals of Programming Fundamentals of Programming Lecture 3 - Constants, Variables, Data Types, And Operations Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline C Program Data types Variables

More information

primer 2005/1/19 18:36 page 843 #865

primer 2005/1/19 18:36 page 843 #865 primer 2005/1/19 18:36 page 843 #865 Index Bold face numbers refer to the page on which the term was first defined. Numbers in italic refer to the Defined Terms section in which the term is defined....

More information

std::cout << "Size of long = " << sizeof(long) << " bytes\n\n"; std::cout << "Size of char = " << sizeof(char) << " bytes\n";

std::cout << Size of long =  << sizeof(long) <<  bytes\n\n; std::cout << Size of char =  << sizeof(char) <<  bytes\n; C++ Program Structure A C++ program must adhere to certain structural constraints. A C++ program consists of a sequence of statements. Every program has exactly one function called main. Programs are built

More information

Programming. C++ Basics

Programming. C++ Basics Programming C++ Basics Introduction to C++ C is a programming language developed in the 1970s with the UNIX operating system C programs are efficient and portable across different hardware platforms C++

More information

Assertions and Exceptions

Assertions and Exceptions CS 247: Software Engineering Principles Assertions and Exceptions Reading: Eckel, Vol. 2 Ch. 1 Exception Handling U Waterloo CS247 (Spring 2017) p.1/32 Defensive Programming The question isn t whether

More information

Computer Science 306 Study Guide

Computer Science 306 Study Guide Computer Science 306 Study Guide C++ for Programmers Computer Science 306 Study Guide (Print Version) Copyright and Credits - Unit 0 - Introduction to C++ for Programmers Section 1 - The programming environment

More information

About Codefrux While the current trends around the world are based on the internet, mobile and its applications, we try to make the most out of it. As for us, we are a well established IT professionals

More information

VALLIAMMAI ENGINEERING COLLEGE

VALLIAMMAI ENGINEERING COLLEGE VALLIAMMAI ENGINEERING COLLEGE SRM Nagar, Kattankulathur 603 203 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK B.E. - Electrical and Electronics Engineering IV SEMESTER CS6456 - OBJECT ORIENTED

More information

Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p.

Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p. Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p. 9 Self-Test Exercises p. 11 History Note p. 12 Programming and

More information

COMP322 - Introduction to C++ Lecture 02 - Basics of C++

COMP322 - Introduction to C++ Lecture 02 - Basics of C++ COMP322 - Introduction to C++ Lecture 02 - Basics of C++ School of Computer Science 16 January 2012 C++ basics - Arithmetic operators Where possible, C++ will automatically convert among the basic types.

More information

6.096 Introduction to C++ January (IAP) 2009

6.096 Introduction to C++ January (IAP) 2009 MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture

More information

About Codefrux While the current trends around the world are based on the internet, mobile and its applications, we try to make the most out of it. As for us, we are a well established IT professionals

More information

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE PART A UNIT I 1. Differentiate object oriented programming from procedure oriented programming. 2. Define abstraction and encapsulation. 3. Differentiate

More information

Axivion Bauhaus Suite Technical Factsheet AUTOSAR

Axivion Bauhaus Suite Technical Factsheet AUTOSAR Version 6.9.1 upwards Axivion Bauhaus Suite Technical Factsheet AUTOSAR Version 6.9.1 upwards Contents 1. C++... 2 1. Autosar C++14 Guidelines (AUTOSAR 17.03)... 2 2. Autosar C++14 Guidelines (AUTOSAR

More information

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR 603203 DEPARTMENT OF COMPUTER SCIENCE & APPLICATIONS QUESTION BANK (2017-2018) Course / Branch : M.Sc CST Semester / Year : EVEN / II Subject Name

More information

PIC10B/1 Winter 2014 Exam I Study Guide

PIC10B/1 Winter 2014 Exam I Study Guide PIC10B/1 Winter 2014 Exam I Study Guide Suggested Study Order: 1. Lecture Notes (Lectures 1-8 inclusive) 2. Examples/Homework 3. Textbook The midterm will test 1. Your ability to read a program and understand

More information

Unit 4 Basic Collections

Unit 4 Basic Collections Unit 4 Basic Collections General Concepts Templates Exceptions Iterators Collection (or Container) Classes Vectors (or Arrays) Sets Lists Maps or Tables C++ Standard Template Library (STL Overview A program

More information

Chapter 2. Procedural Programming

Chapter 2. Procedural Programming Chapter 2 Procedural Programming 2: Preview Basic concepts that are similar in both Java and C++, including: standard data types control structures I/O functions Dynamic memory management, and some basic

More information

Index. Symbols. bit sequence, 27 ^ (exclusive OR) operator, 30 hexadecimal number, 27 left shift (<<) operator, 31 right shift (>>) operator, 32

Index. Symbols. bit sequence, 27 ^ (exclusive OR) operator, 30 hexadecimal number, 27 left shift (<<) operator, 31 right shift (>>) operator, 32 Symbols && operator, 32 operator, 32 A AddDynamicOption method, 188 AddItem method, 192 Addition operator, 18 Allocating memory, 228 overloaded delete function, 233 overloaded new function, 232 unnamed

More information

Lecture 10. To use try, throw, and catch Constructors and destructors Standard exception hierarchy new failures

Lecture 10. To use try, throw, and catch Constructors and destructors Standard exception hierarchy new failures Lecture 10 Class string Exception Handling To use try, throw, and catch Constructors and destructors Standard exception hierarchy new failures Class template auto_ptr Lec 10 Programming in C++ 1 Class

More information

IBM i Version 7.2. Programming IBM Rational Development Studio for i ILE C/C++ Language Reference IBM SC

IBM i Version 7.2. Programming IBM Rational Development Studio for i ILE C/C++ Language Reference IBM SC IBM i Version 7.2 Programming IBM Rational Development Studio for i ILE C/C++ Language Reference IBM SC09-7852-03 IBM i Version 7.2 Programming IBM Rational Development Studio for i ILE C/C++ Language

More information

To use various types of iterators with the STL algorithms ( ). To use Boolean functions to specify criteria for STL algorithms ( 23.8).

To use various types of iterators with the STL algorithms ( ). To use Boolean functions to specify criteria for STL algorithms ( 23.8). CHAPTER 23 STL Algorithms Objectives To use various types of iterators with the STL algorithms ( 23.1 23.20). To discover the four types of STL algorithms: nonmodifying algorithms, modifying algorithms,

More information

Review of the C Programming Language for Principles of Operating Systems

Review of the C Programming Language for Principles of Operating Systems Review of the C Programming Language for Principles of Operating Systems Prof. James L. Frankel Harvard University Version of 7:26 PM 4-Sep-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights

More information

Programming with Haiku

Programming with Haiku Programming with Haiku Lesson 2 Written by DarkWyrm All material 2010 DarkWyrm In our first lesson, we learned about how to generalize type handling using templates and some of the incredibly flexible

More information

C++_ MARKS 40 MIN

C++_ MARKS 40 MIN C++_16.9.2018 40 MARKS 40 MIN https://tinyurl.com/ya62ayzs 1) Declaration of a pointer more than once may cause A. Error B. Abort C. Trap D. Null 2Whice is not a correct variable type in C++? A. float

More information

Programming in C++ 4. The lexical basis of C++

Programming in C++ 4. The lexical basis of C++ Programming in C++ 4. The lexical basis of C++! Characters and tokens! Permissible characters! Comments & white spaces! Identifiers! Keywords! Constants! Operators! Summary 1 Characters and tokens A C++

More information

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering

More information

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University CS5000: Foundations of Programming Mingon Kang, PhD Computer Science, Kennesaw State University Overview of Source Code Components Comments Library declaration Classes Functions Variables Comments Can

More information

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

CprE 288 Introduction to Embedded Systems Exam 1 Review.  1 CprE 288 Introduction to Embedded Systems Exam 1 Review http://class.ece.iastate.edu/cpre288 1 Overview of Today s Lecture Announcements Exam 1 Review http://class.ece.iastate.edu/cpre288 2 Announcements

More information

Review of the C Programming Language

Review of the C Programming Language Review of the C Programming Language Prof. James L. Frankel Harvard University Version of 11:55 AM 22-Apr-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. Reference Manual for the

More information

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING Unit I : OVERVIEW PART A (2 Marks) 1. Give some characteristics of procedure-oriented

More information

SAURASHTRA UNIVERSITY

SAURASHTRA UNIVERSITY SAURASHTRA UNIVERSITY RAJKOT INDIA Accredited Grade A by NAAC (CGPA 3.05) CURRICULAM FOR B.Sc. (Computer Science) Bachelor of Science (Computer Science) (Semester - 1 Semester - 2) Effective From June

More information

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17 List of Programs xxv List of Figures xxix List of Tables xxxiii Preface to second version xxxv PART 1 Structured Programming 1 1 Getting started 3 1.1 Programming 3 1.2 Editing source code 5 Source code

More information

APPENDIX A : KEYWORDS... 2 APPENDIX B : OPERATORS... 3 APPENDIX C : OPERATOR PRECEDENCE... 4 APPENDIX D : ESCAPE SEQUENCES... 5

APPENDIX A : KEYWORDS... 2 APPENDIX B : OPERATORS... 3 APPENDIX C : OPERATOR PRECEDENCE... 4 APPENDIX D : ESCAPE SEQUENCES... 5 APPENDIX A : KEYWORDS... 2 APPENDIX B : OPERATORS... 3 APPENDIX C : OPERATOR PRECEDENCE... 4 APPENDIX D : ESCAPE SEQUENCES... 5 APPENDIX E : ASCII CHARACTER SET... 6 APPENDIX F : USING THE GCC COMPILER

More information

LEXICAL 2 CONVENTIONS

LEXICAL 2 CONVENTIONS LEXIAL 2 ONVENTIONS hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. ++ Programming Lexical onventions Objectives You will learn: Operators. Punctuators. omments. Identifiers. Literals. SYS-ED \OMPUTER EDUATION

More information

Major Language Changes, pt. 1

Major Language Changes, pt. 1 C++0x What is C++0x? Updated version of C++ language. Addresses unresolved problems in C++03. Almost completely backwards compatible. Greatly increases expressiveness (and complexity!) of language. Greatly

More information

END TERM EXAMINATION

END TERM EXAMINATION END TERM EXAMINATION THIRD SEMESTER [BCA] DECEMBER 2007 Paper Code: BCA 209 Subject: Object Oriented Programming Time: 3 hours Maximum Marks: 75 Note: Attempt all questions. Internal choice is indicated.

More information

Ch. 12: Operator Overloading

Ch. 12: Operator Overloading Ch. 12: Operator Overloading Operator overloading is just syntactic sugar, i.e. another way to make a function call: shift_left(42, 3); 42

More information