summaryrefslogtreecommitdiff
path: root/C++_Demystified:_A_Self-Teaching_Guide/chapter11.ipynb
diff options
context:
space:
mode:
authorHardik Ghaghada2014-06-20 15:52:25 +0530
committerHardik Ghaghada2014-06-20 15:52:25 +0530
commite1e59ca3a50d9f93e8b7bc0693b8081d5db77771 (patch)
treef54eab21dd3d725d64a495fcd47c00d37abed004 /C++_Demystified:_A_Self-Teaching_Guide/chapter11.ipynb
parenta78126bbe4443e9526a64df9d8245c4af8843044 (diff)
parent83c1bfceb1b681b4bb7253b47491be2d8b2014a1 (diff)
downloadPython-Textbook-Companions-e1e59ca3a50d9f93e8b7bc0693b8081d5db77771.tar.gz
Python-Textbook-Companions-e1e59ca3a50d9f93e8b7bc0693b8081d5db77771.tar.bz2
Python-Textbook-Companions-e1e59ca3a50d9f93e8b7bc0693b8081d5db77771.zip
Merge pull request #1 from debashisdeb/master
removing problem statements from all the chapters to avoid copyright violations
Diffstat (limited to 'C++_Demystified:_A_Self-Teaching_Guide/chapter11.ipynb')
-rw-r--r--C++_Demystified:_A_Self-Teaching_Guide/chapter11.ipynb99
1 files changed, 21 insertions, 78 deletions
diff --git a/C++_Demystified:_A_Self-Teaching_Guide/chapter11.ipynb b/C++_Demystified:_A_Self-Teaching_Guide/chapter11.ipynb
index f1d28b76..28bea5a9 100644
--- a/C++_Demystified:_A_Self-Teaching_Guide/chapter11.ipynb
+++ b/C++_Demystified:_A_Self-Teaching_Guide/chapter11.ipynb
@@ -1,6 +1,7 @@
{
"metadata": {
- "name": ""
+ "name": "",
+ "signature": "sha256:3856d250c0b05978b896337a2d03bfbc47b52567398ed488a9db68479c713e89"
},
"nbformat": 3,
"nbformat_minor": 0,
@@ -27,10 +28,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "size of pointers\n",
- "note: there is no concept of pointers in python\n",
- "\"\"\"\n",
+ "\n",
"\n",
"import sys\n",
"\n",
@@ -69,10 +67,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "attempt to print the value of pointer.\n",
- "note: there is no pointer in python, we will simply print out an integer value instead\n",
- "\"\"\"\n",
+ "\n",
"\n",
"iPtr = 0\n",
"print \"The value of iPtr is\", iPtr"
@@ -102,9 +97,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "Null pointers\n",
- "\"\"\"\n",
+ "\n",
"\n",
"iPtr = None\n",
"print \"The value of iPtr is \", iPtr"
@@ -134,9 +127,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "address of pointers\n",
- "\"\"\"\n",
+ "\n",
"\n",
"num = 5\n",
"iPtr = id(num)\n",
@@ -169,10 +160,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "dereferencing\n",
- "output will deffer from that given in textbook\n",
- "\"\"\"\n",
+ "\n",
"\n",
"num = 5\n",
"iPtr = id(num)\n",
@@ -209,10 +197,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "Pointer as a Variable\n",
- "note: output may differ from that given in textbook\n",
- "\"\"\"\n",
+ "\n",
"\n",
"num1 = 5\n",
"num2 = 14\n",
@@ -253,11 +238,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "array name as a constant pointer\n",
- "note: we cannot use * operator to point in python as there are no pointers\n",
- "python\n",
- "\"\"\"\n",
+ "\n",
"\n",
"testScore = [4, 7, 1]\n",
"print \"The address of the array using testScore is \", testScore\n",
@@ -293,10 +274,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "Pointer Arithmetic\n",
- "the adress values will be different\n",
- "\"\"\"\n",
+ "\n",
"\n",
"MAX = 3\n",
"\n",
@@ -335,10 +313,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "previous program modified with a pointer to point to array\n",
- "the adress values will be different\n",
- "\"\"\"\n",
+ "\n",
"\n",
"MAX = 3\n",
"\n",
@@ -378,11 +353,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "Incrementing a Pointer\n",
- "the method given in textbook is not possible in python.\n",
- "We will do it in different way\n",
- "\"\"\"\n",
+ "\n",
"\n",
"MAX = 3\n",
"\n",
@@ -422,9 +393,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "comparing address\n",
- "\"\"\"\n",
+ "\n",
"import sys\n",
"MAX = 3\n",
"\n",
@@ -489,10 +458,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "decrementing pointers\n",
- "Note: not possible in python. Impletement in a different way\n",
- "\"\"\"\n",
+ "\n",
"import sys\n",
"MAX = 3\n",
"\n",
@@ -536,9 +502,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "pointer as function\n",
- "\"\"\"\n",
+ "\n",
"\n",
"MAX = 3\n",
"\n",
@@ -627,10 +591,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "pointer as function\n",
- "the program remains same in python\n",
- "\"\"\"\n",
+ "\n",
"\n",
"MAX = 3\n",
"\n",
@@ -719,9 +680,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "Passing a Single Variable Using Pointer Notation\n",
- "\"\"\"\n",
+ "\n",
"\n",
"def doubleIt(x):\n",
" print \"The number to be doubled is \", x\n",
@@ -776,12 +735,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "modify previous program so it passes the variable to be doubled by address instead of by\n",
- "reference\n",
"\n",
- "note: in python it will remain same\n",
- "\"\"\"\n",
"\n",
"def doubleIt(x):\n",
" print \"The number to be doubled is \", x\n",
@@ -836,9 +790,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "Dynamic Memory Allocation\n",
- "\"\"\"\n",
+ "\n",
"\n",
"print \"Enter the number of test scores: \",\n",
"numTests = int(raw_input())\n",
@@ -937,9 +889,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "Returning Pointers from Functions\n",
- "\"\"\"\n",
+ "\n",
"\n",
"str = \"Jeff Kent\"\n",
"print str"
@@ -969,9 +919,6 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "Returning a Pointer to a Local Variable\n",
- "\"\"\"\n",
"\n",
"def setName():\n",
" print \"Enter your name: \",\n",
@@ -1021,9 +968,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "Returning a Pointer to a Static Local Variable\n",
- "\"\"\"\n",
+ "\n",
"\n",
"def setName():\n",
" print \"Enter your name: \",\n",
@@ -1073,9 +1018,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\"\"\"\n",
- "Returning a Pointer to a Dynamically Created Variable\n",
- "\"\"\"\n",
+ "\n",
"\n",
"def setName():\n",
" print \"Enter your name: \",\n",