answersLogoWhite

0

What is c plus plus data type?

Updated: 8/11/2023
User Avatar

Wiki User

12y ago

Best Answer

The C++ string classes are derived from the std::basic_string<T> template class, where T is a character type. The standard provides the two most common string types, std::string (std::basic_string<char>) and std::wstring (std::basic_string<wchar_t>). The former is used for ASCII strings (which includes UTF-8 strings) while the latter is used for wide-character strings, particularly UNICODE strings.

All standard library strings are represented by an array of some character type (such as char or wchar_t) however, unlike an ordinary array, the individual character elements cannot be re-ordered other by overwriting each character. If you simply need an array of characters that can be re-ordered then use a std::vector<char> or std::vector<wchar_t> rather than a string.

The standard library strings include a rich set of methods, operations and algorithms that are commonly used with strings, such as std::string::find() to locate a character within a string, std::string::substr() to extract a substring from a string, and operator+= to concatenate one string onto another. Most implementations include the short string optimisation so that short strings (up to around 14 characters or so) may be stored in local memory rather than on the heap. Many strings tend to be short so this can provide enormous performance benefits with little cost in terms of memory.

User Avatar

Wiki User

7y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

Not necessarily, but it depends on what you mean by "string data type".

Both C and C++ support the concept of an array of char, such as...

char szMystring[] = "This is a test";

... or ...

char *pszMystring = "This is also a test";

... or ...

char *pszString = malloc (strlen("This is a third test") + 1);

if (pszString == NULL) ... throw exception ...

strcpy (pszString, "This is a third test"); /* must be the same length as in the malloc call */

... use the string ...

free (pszString);

...but that is a fixed length string of length one more than the actual length, to allow for a null terminator, but that is not dynamic, and needs to be reallocated if changed.

Many C++ class libraries, however, support true variable length, dynamic strings, that behave as if they were native types, but that is a function of the class library, not of the C++ language.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

data types mean to indentify the type of data and associated operations of handling it

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is c plus plus data type?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

User defined data type in c plus plus?

Use "typedef" : both in C and C++.


Can an integer data type in c plus plus stores character value?

no


What use of void data type in c plus plus?

doesn't return the value.


What is difference between '1' and 1 as for us a computer is concerned with respect to c plus plus?

When you type '1' in a C++ program, it is considered to be of character data type(char). When you type 1, it is considered to be of integer data type.


What are logical classes in c plus plus?

There is no such thing. Logic is bitwise operation, not a data type.


What Lead to C C plus plus and java?

(C and Lisp, ... data type") was adopted by many later languages, such as ALGOL 68 (1970), Java, and C#. ... C++ has a separate Boolean data type ( 'bool' ), but with automatic conversions from ... "Report on the Algorithmic Language ALGOL 68


What is the difference between class data type and basic type in c plus plus .How can someone know which one is class type and which one is basic type.?

Basic types (primitive data types) have no methods associated with them.


Defference between c plus plus and c?

these are difference in between c and c++: a) C is a SPL and C++ is a OOP. b) C has not concept of object but C++ has this feature. c) C has not 'class' name data type but C++ has.


What is different between primitive date type and non primitive data type in c plus plus programming language?

A primitive data type is built into the language - int, char, long, etc. A non-primitive data type is am abstract data type that is built out of primitive data types - linked list, queue, stack, etc.


Why c plus plus called as paritial oop?

C++ is only partially OOP because it is a superset of C and, for the sake of backward compatibility, retains the concept of primitive data types (such as integrals like char and int) and pointer data types, which are all strictly non-object-oriented. In Java and C#, there is no concept of a primitive data type. Even integral types such as int are treated as objects and there is no concept of a pointer data type.


What is the c plus plus command to read a line?

You can use cin which located in iostream.h You have to use certain data type to read string, for instance, array of char


What does tbuffer mean in c plus plus?

There is no such keyword or data type known as tbuffer in C++. It's most likely an user-defined identifier, possibly a text buffer. But without knowing its actual type or its context it's impossible to say what it means.