Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First, in C++ you should not use "raw" pointers. </p> <p>Now, about your problem: error message says: "invalid conversion from const char* to int".</p> <pre><code>int andy = "25"; </code></pre> <p><code>"25"</code> is a string literal (with type <code>const char*</code>). You want an integer constant instead:</p> <p>int andy = 25;</p> <p>Now - <code>andy</code> is not a pointer, so you can't apply <code>*</code> operator - and this is the reason of your second error (<code>invalid type argument of unary '*'</code>). </p> <p>Finally, read a book, or a tutorial on these, as you're not using pointers anywhere in your code, you're just blindly using <code>&amp;</code> and <code>*</code> operators.</p> <p>This could be an example of using pointers:</p> <pre><code>int andy = 25; int *andy1 = &amp;andy; // andy1 is the pointer - see star after type declaration // with &amp;andy we're assigning the address of andy variable to it int andyand = *andy1; // star before pointer is dereferencing - reads the value of the memory // address where pointer is pointing to. So, *andy1 evaluates to 25 cout &lt;&lt; "hello" &lt;&lt; endl &lt;&lt; andy &lt;&lt; endl &lt;&lt; *andy1 &lt;&lt; andyand; </code></pre> <p>Oh, everyone noted this except me - unfortunately (for both you and us), there's no <code>import</code> directive in C++ - but <a href="http://isocpp.org/blog/2012/11/modules-update-on-work-in-progress-doug-gregor" rel="nofollow">it should be with us in a few years</a>.</p>
 

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