c++ - String::New: what is it? -


I am from Java background and learning C ++ I had to face the following C ++ code:

string = new ("hello '+', 'world');

As I still understand, this static member The function should be a call for the 'New' class 'string'. However, I have searched the entire header file defining 'Harry String', string class or its new class 'New' There is no specific member associated with the new member function in string class or C ++?

You are calling stable method new on the correct string class.

C ++ (Or STL) does not have the original string class, there is a string , but in :: new No method, you must make sure that you have the right documentation It is possible that it is inherited from a base-class, so make sure that you check that if the string is a part of , a legacy hierarchy Of

Here is the deal with the string of V8. This is interesting.

There are two implementations:

  • - One that appears externally (showing class hierarchy here).
  • - Internal representation.

Browsing, string is actually a heap assigned object that represents the Javascript string.

It has been discovered that the Google Code UI has broken (perhaps they have the maximum character count?) It should be in src / objects.h , but minimize the file has given. And the external view should be in the included / v8.h , but it is also small.

You can download the source and view the files. Here's what:

  / ** * JavaScript String Value (ECMA-262, 4.3.17). * / Class V8EXPORT String: Public Primitive {Public: ... / ** * either allocates a new string with UTF-8 encoded or ASCI data. * Second parameter gives length 'buffer length * If the data is UTF-8 encoded, then be careful to supply the length parameter to the collar. * If this is not given, the function calls the '* strlen' to determine buffer length, then 'wrong' if 'data' contains zero characters * / static local & lt; String & gt; New (const char * data, int length = -1); / ** assigns a new string to the utf16 data. * / Stable local & lt; String & gt; New (constant UIT 16_T * data, int length-1); ...};  

Comments