<p>I have been trying to include a file in a included file e.g</p>

<p><strong>main.cpp file</strong></p>

<pre><code>#include &lt;includedfile.cpp&gt;
int main(){
     cout&lt;&lt;name&lt;&lt;endl;
}
</code></pre>

<p><strong>includedfile.cpp</strong></p>

<pre><code>#include &lt;iostream&gt;
using namespace std;
string name;
name = "jim";
</code></pre>

<p>this code does not work, the debuger says that name is not defined.</p>

You cannot have statements exist outside of a method!
```
```
name = "jim"; // This is outside of any method, so it is an error.
```
```
You could refactor your code so the variable declaration is also an initial assignment, which should be valid (my C++ is a bit rusty, so I might be wrong on this point).
```
```
string name = "jim";
```
```