This interview question come from a famous communication firm of china. : ) #include <iostream> #include <stdio.h> #include <string.h> #include <conio.h> using namespace std; int main() { float a = 1.0f; cout << cout <<
ANSIC允许声明常量,常量和变量不同,常量就是不可以改变的量,用关键字const来修饰 比如:const int a int const a 以上两种声明方式是一样的,我们不需要考虑const和int的先后顺序,按照你理解的方便的一中方式进行应用. 因为const和int的顺序先后并不影响结果,因此 int const * && const int *这两中情况就是一样的 所以我们只需要讨论两种情况 -----------------------------------------
首先注意,const int * p 和int const *p 是一样的,并且不管是不是*p,即使const int i和int const i也是一样的,所以我们接下来只讨论int const * p和int * const p的不同 对于这种问题,我们只用将const 的位置固定,然后再看后面的东西,一般规则是后面的东西不能在进行赋值或者修改.例如下面: #include<stdio.h> int main(int argc,char *argv[]) { int i = 10; int
int i = -1;bool b = int.TryParse(null, out i);执行完毕后,b等于false,i等于0,而不是等于-1,切记. int i = -1;bool b = int.TryParse("123", out i); 执行完毕后,b等于true,i等于123: 1.(int)是一种类型转换:当我们觟nt类型到long,float,double,decimal类型,可以使用隐式转换,但是当我们从long类型到int类型就需要使用显式转换,否则会产生编译错