<> One ,c++ New data types in
Let's take a look first c Data type of
These are c Language data type
And in the c++ New in **bool( Boolean type )** Its value is true or false, This type is c Not in the language .
<> Two ,c++ Initialization method in
c Initialization method of language c++ Initialization method of
Assignment initialization int x=1024 ; Assignment initialization int x=1024; Direct initialization int x(1024);
<> Three ,c++ Define as you go
C language
int main() { int x; float y; x=1; y=2.5; return 0; }
C++
int main() { int x; x=1; float y; y=2.5; return 0; }
We can see from the above two examples ,c In language, the variable definition must be at the front of the function body , and c++ All variables are defined as they are used
<> Four ,c++ Input and output of
Let's have a look first c General input and output process in language
and c++ The input process is as follows :
As can be seen from the two figures above
c++ That is to say c Of printf Change to cout, hold scanf Change to cin
of course c++ The input and output code style is also simpler , The code is as follows
#include <iostream> using namespace std;// This is a namespace , The next article will talk about it , Knock first int main(void) {
int x,y; cin >> x>>y; cout<<x<<y<<endl;
// Between variables , Between variables and characters << connect , among endl amount to \n For carriage return return 0; }
Technology