我有办法访问尚未声明的结构吗?
//Need to some how declare 'monitor' up here, with out moving 'monitor' above 'device'
//because both structs need to be able to access each others members
struct{
int ID = 10;
int Get__Monitor__ID(){
return monitor.ID; //obvioulsly 'monitor' is not declared yet, therefore throws error and is not accessible
}
} device;
struct{
int ID = 6;
int Get__Device__ID(){
return device.ID; //because 'device' is declared above this struct, the ID member is accessible
}
} monitor;
Run Code Online (Sandbox Code Playgroud) 我正在尝试找到一种方法来检查浮点数是否为负而不分支。
float a = -0.5;
int getSignOfa= *(int*)&a >> 31; //type-pun to int and get signed bit;
Run Code Online (Sandbox Code Playgroud)
这是检查浮点数有符号位的安全方法吗?