forked from peter-can-write/cpp-notes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimplicit-conversion-operators.html
More file actions
17 lines (17 loc) · 1.59 KB
/
implicit-conversion-operators.html
File metadata and controls
17 lines (17 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><meta name="exporter-version" content="Evernote Mac 6.3 (452849)"/><meta name="altitude" content="518"/><meta name="author" content="petergoldsborough@hotmail.com"/><meta name="created" content="2015-02-28 17:09:09 +0000"/><meta name="latitude" content="46.62858276367184"/><meta name="longitude" content="13.82443237304688"/><meta name="source" content="desktop.mac"/><meta name="updated" content="2015-02-28 17:09:18 +0000"/><title>Implicit conversion operators</title></head><body>
<div>
<div><span style="font-family: 'Helvetica Neue';">You can explicitly define conversion operators for classes. </span></div>
<div><span style="font-family: 'Helvetica Neue';"><br/></span></div>
<div><span style="font-family: 'Helvetica Neue';">class Foo</span></div>
<div><span style="font-family: 'Helvetica Neue';">{</span></div>
<div><span style="font-family: 'Helvetica Neue';"> public:</span></div>
<div><span style="font-family: 'Helvetica Neue';"> </span></div>
<div><span style="font-family: 'Helvetica Neue';"> operator double();</span></div>
<div><span style="font-family: 'Helvetica Neue';">};</span></div>
<div><span style="font-family: 'Helvetica Neue';"><br/></span></div>
<div><span style="font-family: 'Helvetica Neue';">This would define an explicit conversion from Foo to double.</span></div>
</div>
<div><br/></div>
</body></html>