Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>CCString *s_piece__locks = "TEST"; cocos2d::CCString *s_piece__locks2 = "TEST"; </code></pre> <p>What the heck is this supposed to do? Declaring a pointer does not generate any object except the pointer itself. So basically, for this to "work", there would need to be another <code>CCString</code> object around already, that happens to represent the string "TEST". But even if that's given, how is C++ supposed to know which one to point to? It would need to look <code>"TEST"</code> up in some kind of e.g. hash map.</p> <p>None of this makes any sense. Change your code to either</p> <ul> <li><p>Direct use of object on stack:</p> <pre><code>cocos2d::CCString s_piece; s_piece = "TEST"; </code></pre></li> <li><p>Assigning new content to an object that resides somewhere else. You'd normally use a <em>reference</em> for this, e.g.</p> <pre><code>void assign_test_to(cocos2d::CCString&amp; target) { target = "TEST"; } </code></pre> <p>it's also possible with a pointer</p> <pre><code>void assign_test_to_ptr(cocos2d::CCString* target) { *target = "TEST"; } </code></pre> <p>but don't do that unless you have a specific reason to.</p></li> </ul> <p>In principle, there's another possibility:</p> <pre><code>cocos2d::CCString* s_piece_locks = new CCString; *s_piece_locks = "TEST"; </code></pre> <p>but you want to avoid this, as it can very easily lead to memory leaks. What would be ok is</p> <pre><code>std::unique_ptr&lt;cocos2d::CCString&gt; s_piece_locks = new CCString; *s_piece_locks = "TEST"; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload