Lecture 17 h.stlstr.pdf - Introduction to Object-Oriented Programming COMP2011 C String Class Prof Andrew Horner Dr Cecia Chan Dr Cindy Li Department of

Lecture 17 h.stlstr.pdf - Introduction to Object-Oriented...

This preview shows page 1 - 4 out of 12 pages.

Introduction to Object-Oriented Programming COMP2011: C++ String Class Prof. Andrew Horner Dr. Cecia Chan Dr. Cindy Li Department of Computer Science & Engineering The Hong Kong University of Science and Technology Hong Kong SAR, China developed by Prof. Brian Mak { horner, kccecia, lixin } @cse.ust.hk COMP2011 (Spring 2018) p.1
Image of page 1
Introduction C strings consist of a sequence of characters terminated by the ’ \ 0’ character, and are stored as char arrays . C string is not a basic data type and does not natively support any operations which are, instead, provided by a set of functions defined in the cstring library. There is a C++ string class which allows you to manipulate string objects as if they are from a basic type. string construction and initialization input and output indexing comparisons substrings swapping strings string length finding substrings and characters replacing characters in string inserting characters in string { horner, kccecia, lixin } @cse.ust.hk COMP2011 (Spring 2018) p.2
Image of page 2
Common Public Member Functions string::append string::assign string::at string::begin string::capacity string::clear string::compare string::copy string::c str string::data string::empty string::end string::erase string::find string::find first not of string::find first of string::find last not of string::find last of string::insert string::length string::max size string::operator= string::operator+= string::operator[ ] string::push back string::rbegin string::rend string::replace string::resize string::rfind string::size string::substr string::swap { horner, kccecia, lixin } @cse.ust.hk COMP2011 (Spring 2018) p.3
Image of page 3
Image of page 4

You've reached the end of your free preview.

Want to read all 12 pages?

  • Spring '17
  • wert
  • ASCII, String object, Prof. Andrew Horner

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes