11c++ string manipulation

Source: Internet
Author: User

First, the definition is initialized

Second, common operation

Instance:

1#include <stdlib.h>2#include <iostream>3#include <string>4 using namespacestd;5 classStudent6 {7  Public:8     voidSetName (string_name)9     {TenM_strname=_name; One  A     } -     stringGetName () -     { the         returnM_strname; -     } -     voidSetgender (string_gender) -     { +M_strgender=_gender; -  +     } A     stringGetgender () at     { -         returnM_strgender; -     } -     intGetscore ()//int represents his return value. -     { -  in         returnM_iscore; -     } to     voidInitscore () +     { -M_iscore=0; the     } *     voidStudyint_score) $     {Panax Notoginsengm_iscore+=_score; -     } the Private: +     stringM_strname; A     stringM_strgender; the     intM_iscore; + }; - intMainvoid) $ { $ Student Stu; -Stu.initscore ();//Initialize the credits -Stu.setname ("David Han"); theStu.setgender ("male"); -Stu.study ( -);WuyiCout<<stu.getname () <<endl<<stu.getgender () <<endl<<stu.getscore () <<endl;//Be sure to add parentheses here, because the parentheses are the function theSystem"Pause"); -     return 0; Wu}

11c++ string manipulation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.