C + + foundation — errors prone to occur during pointer definition

Time:2021-9-16

Pointer definition is prone to errors

When defining a pointer, remember to write “*” together with the pointer variable, not with the basic data type char.

#include 
#include 
using namespace std;

int main(){
	//It is equivalent to defining two variables, one is char * P1 and the other is char P2 
	char *p1, p2;
	Printf ("data type of P1 is:% s \ n", typeID (P1). Name()); 
	Printf ("the data type of P2 is:% s \ n", typeID (P2). Name()); 
	

	//It is equivalent to defining two variables, one is char * P3 and the other is char * P4 
	typedef char *point;
	point p3,p4;
	Printf ("data type of P3 is:% s \ n", typeID (P3). Name()); 
	Printf ("P4's data type is:% s", typeID (P4). Name()); 
    
    /**The results are as follows
        The data type of P1 is PC
	The data type of P2 is: C
	The data type of P3 is PC
	The data type of P4 is PC
	**/
}

Recommended Today

The selector returned by ngrx store createselector performs one-step debugging of fetching logic

Test source code: import { Component } from ‘@angular/core’; import { createSelector } from ‘@ngrx/store’; export interface State { counter1: number; counter2: number; } export const selectCounter1 = (state: State) => state.counter1; export const selectCounter2 = (state: State) => state.counter2; export const selectTotal = createSelector( selectCounter1, selectCounter2, (counter1, counter2) => counter1 + counter2 ); // […]