如何在子结构运算符之间共享变量 [英] How to share a variable between child struct operators

查看:74
本文介绍了如何在子结构运算符之间共享变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个结构网格,每个结构都有自己的属性.目前,每一个都包含6个布尔值,我读过的每个布尔值都占用32位.我想尝试为每个方块用一个字节替换那些布尔值,然后添加六个结构 用运算符将​​每个按位(&)的字节都设为bool,如果设置了相关的位,则返回"true".

I'm creating a grid of structs, each with it's own attributes.  For now each one contain 6 bools though, which I've read take up 32 bits each.  I want to try replacing those bools with a single byte for each square, and then add six structs with an operator bool each that bitwise (&) the byte and returns 'true' if the relevant bit is set...

我认为我可以通过添加一个父母"来解决这种情况.每个孩子的变量,我都可以通过它访问父母变量,但是它不适用于结构,在这种情况下,无论如何都会达到目的.

I think I got around this kind of thing at one point by adding a "parent" variable to each of the children, I could access the parents variables through that, but it won't work with structs, and in this case it would defeat the purpose anyway.

推荐答案

我不确定这个问题是什么.............. .
I'm not exactly sure what the question is ...............


这篇关于如何在子结构运算符之间共享变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆