{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 变量与基本类型" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "int a;" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "int *b = &a" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\u001b[1minput_line_9:2:7: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1mnon-const lvalue reference to type 'int' cannot bind to a value of unrelated type 'int *'\u001b[0m\n", " int &c = b\n", "\u001b[0;1;32m ^ ~\n", "\u001b[0m" ] }, { "ename": "Interpreter Error", "evalue": "", "output_type": "error", "traceback": [ "Interpreter Error: " ] } ], "source": [ "int &c = b" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "int c = b" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "int a = 0;" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "C++11", "language": "C++11", "name": "xcpp11" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".cpp", "mimetype": "text/x-c++src", "name": "c++", "version": "11" } }, "nbformat": 4, "nbformat_minor": 2 }