[READ-ONLY] Mirror of https://github.com/shuuji3/cpp-notebook.
0

Configure Feed

Select the types of activity you want to include in your feed.

cpp-notebook / scratch.ipynb
3.8 kB 202 lines
1{ 2 "cells": [ 3 { 4 "cell_type": "code", 5 "execution_count": 1, 6 "metadata": {}, 7 "outputs": [ 8 { 9 "data": { 10 "text/plain": [] 11 }, 12 "execution_count": 1, 13 "metadata": {}, 14 "output_type": "execute_result" 15 } 16 ], 17 "source": [ 18 "#include <iostream>\n", 19 "#include <vector>" 20 ] 21 }, 22 { 23 "cell_type": "code", 24 "execution_count": 2, 25 "metadata": {}, 26 "outputs": [ 27 { 28 "data": { 29 "text/plain": [ 30 "(std::vector<int> &) { 1, 2, 3 }\n" 31 ] 32 }, 33 "execution_count": 2, 34 "metadata": {}, 35 "output_type": "execute_result" 36 } 37 ], 38 "source": [ 39 "std::vector<int> v{1,2,3};\n", 40 "v" 41 ] 42 }, 43 { 44 "cell_type": "code", 45 "execution_count": 3, 46 "metadata": {}, 47 "outputs": [ 48 { 49 "data": { 50 "text/plain": [] 51 }, 52 "execution_count": 3, 53 "metadata": {}, 54 "output_type": "execute_result" 55 } 56 ], 57 "source": [ 58 "class Circle {\n", 59 " private:\n", 60 " double r;\n", 61 " \n", 62 " public:\n", 63 " Circle(double r_) {\n", 64 " r = r_;\n", 65 " }\n", 66 " double area() {\n", 67 " return r * r;\n", 68 " }\n", 69 "}" 70 ] 71 }, 72 { 73 "cell_type": "code", 74 "execution_count": 4, 75 "metadata": {}, 76 "outputs": [ 77 { 78 "data": { 79 "text/plain": [ 80 "(Circle &) @0x10d6dd408\n" 81 ] 82 }, 83 "execution_count": 4, 84 "metadata": {}, 85 "output_type": "execute_result" 86 } 87 ], 88 "source": [ 89 "auto c1 = Circle(10);\n", 90 "c1;" 91 ] 92 }, 93 { 94 "cell_type": "code", 95 "execution_count": 5, 96 "metadata": {}, 97 "outputs": [ 98 { 99 "data": { 100 "text/plain": [ 101 "(Circle &) @0x10d6dd538\n" 102 ] 103 }, 104 "execution_count": 5, 105 "metadata": {}, 106 "output_type": "execute_result" 107 } 108 ], 109 "source": [ 110 "Circle c2{20};\n", 111 "c2;" 112 ] 113 }, 114 { 115 "cell_type": "code", 116 "execution_count": 6, 117 "metadata": {}, 118 "outputs": [ 119 { 120 "data": { 121 "text/plain": [ 122 "(Circle &) @0x10d6dd668\n" 123 ] 124 }, 125 "execution_count": 6, 126 "metadata": {}, 127 "output_type": "execute_result" 128 } 129 ], 130 "source": [ 131 "auto c3 = Circle{30};\n", 132 "c3;" 133 ] 134 }, 135 { 136 "cell_type": "code", 137 "execution_count": 7, 138 "metadata": {}, 139 "outputs": [ 140 { 141 "name": "stderr", 142 "output_type": "stream", 143 "text": [ 144 "\u001b[1minput_line_15:2:7: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1mdeclaration of variable 'Circle' with deduced type 'auto' requires an\n", 145 " initializer\u001b[0m\n", 146 " auto Circle c4{40};\n", 147 "\u001b[0;1;32m ^\n", 148 "\u001b[0m\u001b[1minput_line_15:2:13: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1mexpected ';' at end of declaration\u001b[0m\n", 149 " auto Circle c4{40};\n", 150 "\u001b[0;1;32m ^\n", 151 "\u001b[0m\u001b[0;32m ;\n", 152 "\u001b[0m\u001b[1minput_line_15:3:1: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1muse of undeclared identifier 'c4'\u001b[0m\n", 153 "c4;\n", 154 "\u001b[0;1;32m^\n", 155 "\u001b[0m" 156 ] 157 }, 158 { 159 "ename": "ename", 160 "evalue": "evalue", 161 "output_type": "error", 162 "traceback": [] 163 } 164 ], 165 "source": [ 166 "auto Circle c4{40};\n", 167 "c4;" 168 ] 169 }, 170 { 171 "cell_type": "code", 172 "execution_count": null, 173 "metadata": {}, 174 "outputs": [], 175 "source": [ 176 "c4.area();" 177 ] 178 }, 179 { 180 "cell_type": "code", 181 "execution_count": null, 182 "metadata": {}, 183 "outputs": [], 184 "source": [] 185 } 186 ], 187 "metadata": { 188 "kernelspec": { 189 "display_name": "C++14", 190 "language": "", 191 "name": "cling-cpp14" 192 }, 193 "language_info": { 194 "codemirror_mode": "c++", 195 "file_extension": ".c++", 196 "mimetype": "text/x-c++src", 197 "name": "c++" 198 } 199 }, 200 "nbformat": 4, 201 "nbformat_minor": 2 202}