Skip to content

Commit 2027f1b

Browse files
committed
Fixup notebooks
1 parent 94be923 commit 2027f1b

File tree

3 files changed

+46
-420
lines changed

3 files changed

+46
-420
lines changed

Diff for: QuantStack-CERN/notebooks/01-xeus-cling.ipynb

+1-239
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"![xeus-cling](images/xeus-cling.svg)"
7+
"![xeus-cling](images/xeus-cling.png)"
88
]
99
},
1010
{
@@ -135,244 +135,6 @@
135135
"marie"
136136
]
137137
},
138-
{
139-
"cell_type": "markdown",
140-
"metadata": {},
141-
"source": [
142-
"# Interpreting the C++ programming language\n",
143-
"\n",
144-
"`cling` has a broad support of the features of C++. You can define functions, classes, templates, etc ..."
145-
]
146-
},
147-
{
148-
"cell_type": "markdown",
149-
"metadata": {},
150-
"source": [
151-
"## Functions"
152-
]
153-
},
154-
{
155-
"cell_type": "code",
156-
"execution_count": null,
157-
"metadata": {},
158-
"outputs": [],
159-
"source": [
160-
"double sqr(double a)\n",
161-
"{\n",
162-
" return a * a;\n",
163-
"}"
164-
]
165-
},
166-
{
167-
"cell_type": "code",
168-
"execution_count": null,
169-
"metadata": {},
170-
"outputs": [],
171-
"source": [
172-
"double a = 2.5;\n",
173-
"double asqr = sqr(a);\n",
174-
"asqr"
175-
]
176-
},
177-
{
178-
"cell_type": "markdown",
179-
"metadata": {},
180-
"source": [
181-
"## Classes"
182-
]
183-
},
184-
{
185-
"cell_type": "code",
186-
"execution_count": null,
187-
"metadata": {},
188-
"outputs": [],
189-
"source": [
190-
"class Foo\n",
191-
"{\n",
192-
"public:\n",
193-
"\n",
194-
" virtual ~Foo() {}\n",
195-
" \n",
196-
" virtual void print(double value) const\n",
197-
" {\n",
198-
" std::cout << \"Foo value = \" << value << std::endl;\n",
199-
" }\n",
200-
"};"
201-
]
202-
},
203-
{
204-
"cell_type": "code",
205-
"execution_count": null,
206-
"metadata": {},
207-
"outputs": [],
208-
"source": [
209-
"Foo bar;\n",
210-
"bar.print(1.2);"
211-
]
212-
},
213-
{
214-
"cell_type": "markdown",
215-
"metadata": {},
216-
"source": [
217-
"## Polymorphism"
218-
]
219-
},
220-
{
221-
"cell_type": "code",
222-
"execution_count": null,
223-
"metadata": {},
224-
"outputs": [],
225-
"source": [
226-
"class Bar : public Foo\n",
227-
"{\n",
228-
"public:\n",
229-
"\n",
230-
" virtual ~Bar() {}\n",
231-
" \n",
232-
" virtual void print(double value) const\n",
233-
" {\n",
234-
" std::cout << \"Bar value = \" << 2 * value << std::endl;\n",
235-
" }\n",
236-
"};"
237-
]
238-
},
239-
{
240-
"cell_type": "code",
241-
"execution_count": null,
242-
"metadata": {},
243-
"outputs": [],
244-
"source": [
245-
"Foo* bar2 = new Bar;\n",
246-
"bar2->print(1.2);\n",
247-
"delete bar2;"
248-
]
249-
},
250-
{
251-
"cell_type": "markdown",
252-
"metadata": {},
253-
"source": [
254-
"## Templates"
255-
]
256-
},
257-
{
258-
"cell_type": "code",
259-
"execution_count": null,
260-
"metadata": {},
261-
"outputs": [],
262-
"source": [
263-
"#include <typeinfo>\n",
264-
"\n",
265-
"template <class T>\n",
266-
"class FooT\n",
267-
"{\n",
268-
"public:\n",
269-
" \n",
270-
" explicit FooT(const T& t) : m_t(t) {}\n",
271-
" \n",
272-
" void print() const\n",
273-
" {\n",
274-
" std::cout << typeid(T).name() << \" m_t = \" << m_t << std::endl;\n",
275-
" }\n",
276-
" \n",
277-
"private:\n",
278-
" \n",
279-
" T m_t;\n",
280-
"};\n",
281-
"\n",
282-
"template <>\n",
283-
"class FooT<int>\n",
284-
"{\n",
285-
"public:\n",
286-
" \n",
287-
" explicit FooT(const int& t) : m_t(t) {}\n",
288-
" \n",
289-
" void print() const\n",
290-
" {\n",
291-
" std::cout << \"m_t = \" << m_t << std::endl;\n",
292-
" }\n",
293-
" \n",
294-
"private:\n",
295-
" \n",
296-
" int m_t;\n",
297-
"};"
298-
]
299-
},
300-
{
301-
"cell_type": "code",
302-
"execution_count": null,
303-
"metadata": {},
304-
"outputs": [],
305-
"source": [
306-
"FooT<double> foot1(1.2);\n",
307-
"foot1.print();"
308-
]
309-
},
310-
{
311-
"cell_type": "code",
312-
"execution_count": null,
313-
"metadata": {},
314-
"outputs": [],
315-
"source": [
316-
"FooT<int> foot2(4);\n",
317-
"foot2.print();"
318-
]
319-
},
320-
{
321-
"cell_type": "markdown",
322-
"metadata": {},
323-
"source": [
324-
"## C++11 / C++14 support"
325-
]
326-
},
327-
{
328-
"cell_type": "code",
329-
"execution_count": null,
330-
"metadata": {},
331-
"outputs": [],
332-
"source": [
333-
"class Foo11\n",
334-
"{\n",
335-
"public:\n",
336-
" \n",
337-
" Foo11() { std::cout << \"Foo11 default constructor\" << std::endl; }\n",
338-
" Foo11(const Foo11&) { std::cout << \"Foo11 copy constructor\" << std::endl; }\n",
339-
" Foo11(Foo11&&) { std::cout << \"Foo11 move constructor\" << std::endl; }\n",
340-
"};"
341-
]
342-
},
343-
{
344-
"cell_type": "code",
345-
"execution_count": null,
346-
"metadata": {},
347-
"outputs": [],
348-
"source": [
349-
"Foo11 f1;\n",
350-
"Foo11 f2(f1);\n",
351-
"Foo11 f3(std::move(f1));"
352-
]
353-
},
354-
{
355-
"cell_type": "code",
356-
"execution_count": null,
357-
"metadata": {},
358-
"outputs": [],
359-
"source": [
360-
"#include <vector>\n",
361-
"\n",
362-
"std::vector<int> v = { 1, 2, 3};\n",
363-
"auto iter = ++v.begin();\n",
364-
"v"
365-
]
366-
},
367-
{
368-
"cell_type": "code",
369-
"execution_count": null,
370-
"metadata": {},
371-
"outputs": [],
372-
"source": [
373-
"*iter"
374-
]
375-
},
376138
{
377139
"cell_type": "markdown",
378140
"metadata": {},

0 commit comments

Comments
 (0)