PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/phoenix/doc/html/phoenix/starter_kit/primitives/references.html

http://hadesmem.googlecode.com/
HTML | 67 lines | 67 code | 0 blank | 0 comment | 0 complexity | b947847b7e850b7817a4ac77274e7c9c MD5 | raw file
 1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 2<html>
 3<head>
 4<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
 5<title>References</title>
 6<link rel="stylesheet" href="../../../boostbook.css" type="text/css">
 7<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
 8<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.0">
 9<link rel="up" href="../primitives.html" title="Primitives">
10<link rel="prev" href="values.html" title="Values">
11<link rel="next" href="arguments.html" title="Arguments">
12</head>
13<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
14<table cellpadding="2" width="100%"><tr><td valign="top"></td></tr></table>
15<hr>
16<div class="spirit-nav">
17<a accesskey="p" href="values.html"><img src="../../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../primitives.html"><img src="../../../images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../images/home.png" alt="Home"></a><a accesskey="n" href="arguments.html"><img src="../../../images/next.png" alt="Next"></a>
18</div>
19<div class="section">
20<div class="titlepage"><div><div><h4 class="title">
21<a name="phoenix.starter_kit.primitives.references"></a><a class="link" href="references.html" title="References">References</a>
22</h4></div></div></div>
23<p>
24          References are functions. They hold a reference to a value stored somewhere.
25          For example, given:
26        </p>
27<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">3</span><span class="special">;</span>
28<span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">s</span> <span class="special">=</span> <span class="string">"Hello World"</span><span class="special">;</span>
29</pre>
30<p>
31          we create <code class="computeroutput"><span class="identifier">references</span></code> to
32          <code class="computeroutput"><span class="identifier">i</span></code> and <code class="computeroutput"><span class="identifier">s</span></code>
33          this way:
34        </p>
35<pre class="programlisting"><span class="identifier">ref</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span>
36<span class="identifier">ref</span><span class="special">(</span><span class="identifier">s</span><span class="special">)</span>
37</pre>
38<p>
39          Like <code class="computeroutput"><span class="identifier">val</span></code>, the expressions
40          above evaluates to a nullary function; the first one returning an <code class="computeroutput"><span class="keyword">int</span><span class="special">&amp;</span></code>,
41          and the second one returning a <code class="computeroutput"><span class="keyword">char</span>
42          <span class="keyword">const</span><span class="special">*&amp;</span></code>.
43        </p>
44<p>
45          (See <a href="../../../../../example/references.cpp" target="_top">references.cpp</a>)
46        </p>
47<div class="sidebar">
48<div class="titlepage"></div>
49<p>
50          <span class="inlinemediaobject"><img src="../../../images/tip.png" alt="tip"></span> Learn more about references <a class="link" href="../../modules/core/references.html" title="References">here.</a>
51        </p>
52</div>
53</div>
54<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
55<td align="left"></td>
56<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010 Joel de Guzman, Dan Marsden, Thomas Heller<p>
57        Distributed under the Boost Software License, Version 1.0. (See accompanying
58        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
59      </p>
60</div></td>
61</tr></table>
62<hr>
63<div class="spirit-nav">
64<a accesskey="p" href="values.html"><img src="../../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../primitives.html"><img src="../../../images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../images/home.png" alt="Home"></a><a accesskey="n" href="arguments.html"><img src="../../../images/next.png" alt="Next"></a>
65</div>
66</body>
67</html>