Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ C ++ string in the end     - Firewall types and instructions (Linux)

- Linux user directory (Linux)

- Using Linux strace command trace / debug a program commonly used options (Linux)

- How to use GRUB2 files directly from the hard disk to run ISO (Linux)

- Ubuntu and Derivatives users install the latest KKEdit 0.0.31 (Linux)

- The principle Httpclient4.4 (HttpClient Interface) (Programming)

- Linux System Getting Started Learning: Disable HTTP forwarding wget in (Linux)

- Spring Data JPA call a stored procedure examples (Programming)

- Hands to teach you to solve Ubuntu error message (Linux)

- JavaScript is implemented without new keywords constructor (Programming)

- Linux network security strategy (Linux)

- How to generate Linux, random password encryption or decryption (Linux)

- How to configure MariaDB replication in CentOS Linux (Database)

- Java polymorphic methods inside constructors complete analysis (Programming)

- Linux Shell introduces (Linux)

- CentOS Linux build SVN server (Server)

- Install Krita 2.8 on Ubuntu 13.10 / 12.04 / 12.10 (Linux)

- RHEL5 multipath configuration (Linux)

- Android Studio Clear Project or Rebuild Project Error (Linux)

- Eclipse, Tomcat configuration JNDI connection Oracle data source example (Server)

 
         
  C ++ string in the end
     
  Add Date : 2018-11-21      
         
         
         
  C ++ string in the end is what?

To answer this question, one should first understand what is basic_string.
Look basic_string statement:

template < class charT, // type definition characters in a string
          class traits = char_traits < charT>, // basic_string :: traits_type
          class Alloc = allocator < charT> // basic_string :: allocator_type
          > Class basic_string;

Visible, basic_string class is essentially a template.
Then explain a little more detail:

1. About char_traits

statement:

template < class charT> struct char_traits;

effect:

Character traits classes specify character properties and provide specific semantics for certain operations on characters and sequences of characters. (From C ++ Referencce, address: http: //www.cplusplus.com/reference/string/char_traits/)

That is: it specifies the attribute of the character, and provides specific semantic role in the characters or character sequences of certain operations.

2. About allocator

statement:

template < class T> class allocator; // at < memory> header file allocator: Splitter

effect:
Allocators are classes that define memory models to be used by some parts of the Standard Library, and most specifically, by STL containers (from C ++ Referencce, address:. Http: //www.cplusplus.com/reference/memory/allocator/? kw = allocator)
That is: It defines part of the standard library is used, in particular STL memory model.

Now let's string declaration:

typedef basic_string < char, char_traits < char>, allocator < char >> string;

Now, we understand, the original is such a thing:

With basic types char instantiate the class template basic_string, to give a specific template class, then, is it typedef string.

In other words, is essentially a template class string is basic_string < char, char_traits < char>, allocator < char >>, string is the corresponding "short." Intuitively understand, string instance of the object (that is string str; the str) is a char sequence, but unlike char * str, stingr str with many good package for their own operations.

ps: basic_string there are other examples, such as:

typedef basic_string < wchar_t, char_traits < wchar_t>, allocator < wchar_t >> wstring;
     
         
         
         
  More:      
 
- Linux security concerns again (Linux)
- After SSH change the default port, how to use Git (Linux)
- Thinking in Java study notes - everything is an object (Programming)
- Sublime Text Add instructions to insert the current time zone (Linux)
- Install Java on RHEL6 (Linux)
- Linear table with a Java implementation of the iterator (Programming)
- Difference Redhat5 and 6 YUM source configuration (Linux)
- iOS used in the development --UITabBarController tag controller (Programming)
- CentOS / Linux NIC set IP address configuration (Linux)
- Linux character device - automatically creates the device nodes and devices (Linux)
- Linux Defensive / mitigate DDOS attacks (Linux)
- To install Ganglia configuration of experience under CentOS 5.5 (Linux)
- Why do you need close contact Rust 1.0 (Programming)
- Zend Studio PHP syntax color scheme to export (Linux)
- About Java 7 module system (Programming)
- Terminal Linux command prints - echo (Linux)
- Linux shell scripts bubble sort (Programming)
- How to Debian Linux the default Python version switch to alternative version (Linux)
- A summary of Java multi-threaded programming - acquaintance multithreading (Programming)
- How to add two-factor authentication for Linux systems SSH (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.