我是一名C++初学者,我正在研究该语言的基础知识.我的书中有一个关于编译器的主题,我的问题是我无法理解文本想要说的内容:
C++是一种编译语言,因此您需要将源代码转换为计算机可以执行的文件.该文件由编译器生成,称为目标代码(.obj),但像"hello world"程序这样的程序由我们编写的部分和C++库的一部分组成.链接器链接程序的这两部分并生成可执行文件(.exe).
为什么我的书告诉计算机执行的文件是带有obj后缀的文件(目标代码),然后说它是带有exe后缀的文件?
我正在学习C++语言,我对类型转换有一些疑问,你能解释一下像这样的表达式会发生什么:
unsigned int u = 10;
int a = -42;
std::cout << u - a << std::endl;
Run Code Online (Sandbox Code Playgroud)
在这里我知道如果我在有两个数学运算符时应用规则,结果将是52.但我想知道当编译器将a转换为无符号值时会发生什么情况会产生一个临时的无符号类型,之后会发生什么?表达式现在应该是10 -4294967254.
当我的书说:流是从设备读取或写入的一系列字符然后我的书说:istream和ostream类型代表输入和输出流(它是什么意思?)究竟是如何做cout和cin工作的?
我不是一个本地语言,当我的书出现时我无法理解:输出操作符将给定值写入给定值ostream.
我正在研究C ++编程语言,正在阅读有关赋值运算符(=)的章节。在C ++中,初始化和赋值操作非常相似,因此我们可以使用相同的符号。
但是我的问题是:当我初始化变量时,我是否正在使用赋值运算符进行操作?当我分配一个变量时,我是否使用赋值运算符来完成它?我认为唯一的区别是初始化和赋值之间的区别,因为当我们初始化一个变量时,我们使用assignmnet运算符为其赋予了一个新值,当我们将其赋给一个变量时,便使用了新值来替换该变量的旧值。赋值运算符。这样对吗 ?
我正在关注下载android studio以及如何设置它的课程,我已经为我的手机下载了正确的驱动程序但是当我尝试运行我的hello world程序时我遇到了问题.
请记住,课程本身建议我更新名为activity_main.xml的文件.这是该文件的先前内容:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.udacity.myapplication.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintLeft_toLeftOf="@+id/activity_main"
app:layout_constraintTop_toTopOf="@+id/activity_main"
app:layout_constraintRight_toRightOf="@+id/activity_main"
app:layout_constraintBottom_toBottomOf="@+id/activity_main" />
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
必须更新此代码才能与视频保持一致.新细分:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.udacity.myapplication.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
当我尝试在手机上运行应用程序时,我得到的是:
Error:(7, 28) No resource found that matches the given name (at ‘paddingBottom’ with value ‘@dimen/activity_vertical_margin’).
Error:(8, 26) No resource found that matches the given name (at ‘paddingLeft’ with value ‘@dimen/activity_horizontal_margin’).
Error:(9, 27) …Run Code Online (Sandbox Code Playgroud) 我正在学习C++编程语言,我的书有问题(编程原理和使用C++实践).我的书说的是:
内存中位的含义完全取决于用于访问它的类型.以这种方式思考:计算机内存不知道我们的类型,它只是内存.只有在我们决定如何解释内存时,内存位才有意义.
你能解释一下这是什么意思吗?请以简单的方式进行,因为我只是一个在3周内学习C++的初学者.