(( (table1.field1 like 'HR%') OR (table1.field1 like 'ABC%' OR table1.field1 like 'XYZ%') ))
这是否意味着
int *x
x 是指向 int 类型的指针还是指向整数值的指针?
x
是一个存储类型值的对象int *
;也就是说,它存储了一个int
对象的地址。
它给出的值是 16。这是什么意思?
这意味着您调用了未定义的行为- 您为类型使用了错误的格式说明符。
打印指针值的正确方法是
printf( "%p\n", (void *) x );
在声明中
int *x;
的初始值x
是不确定的- 它可以是任何东西,从0x00000000
to 0x00000010
( 16
) 到0xDEADBEEF
其他任何东西。
指针变量没有什么神奇之处——它们存储特定类型的值,就像int
变量存储整数值和double
变量存储浮点值一样。
指针声明语法和对指针的操作一开始有点不直观且难以掌握,但指针值本身是比较容易理解的东西;它们只是内存中对象(或函数)的地址1。
没有单一的指针类型 - anint *
是与 a 不同的类型double *
,与 a 不同的类型char *
,等等。不同的指针类型可能有不同的大小或表示,但在 x86 等平台上,它们都具有相同的表示。
在声明中,声明符中存在一元*
表示变量具有指针类型:
T *p; // p is a pointer to T
T *ap[N]; // ap is an array of pointers to T
T (*pa)[N]; // pa is a pointer to an array of T
T *fp(); // fp is a function returning a value of type pointer to T
T (*pf)(); // pf is a pointer to a function returning a value of type T
T **pp; // pp is a pointer to pointer to T - it stores the address of
// an object of type T *
在表达式中,一元运算符的存在*
意味着我们要取消引用指针并获取它所指向的事物的值:
int x = 10;
int *p = &x; // save the address of x in p
printf( "%d\n", *p ); // print the value stored in x by dereferencing p
- 更准确地说,它们是地址的抽象。这些地址是物理地址还是虚拟地址取决于您所在的环境。
1 回答
table1.field1 like 'HR%' OR table1.field1 like 'ABC%' OR table1.field1 like 'XYZ%'
如果 table1.field1 不会经常更改所有这些逻辑,而不是在 html 中包含所有逻辑,那么最好在方法中设置一次布尔值,然后 ng-if 设置该布尔值。这样,您的 html 就不必在每个摘要周期中完成所有这些工作。其次,您可以在控制器而不是 HTML 中更轻松地单步执行您的代码。也使 HTML 更干净。
// in controller
function ControllerFn($scope) {
$scope.vm = {
show: false;
}
function toShow(field) {
if (!field)
return false;
return field.indexOf('HR') > -1 || field.indexOf('ABC') > -1 || field.indexOf('XYZ') > -1;
}
if (table1) {
$scope.vm.show = toShow(table1.field1);
}
}
// html
<div ng-if='vm.show'></div>