繁体   English   中英

如何从另一个类中访问结构?

[英]How to get access to struct in one class from another?

如何访问 B 类中的 randomStruct?

Class A
{
 public:
  struct randomStruct
   {
    // some functions and variables here
   }
}

Class B
{
// and here I need to call my randomStruct from class A
}

这只是一个代码示例

如果您通过电话意味着使用这可能是一个解决方案

Class A
{
 public:
  struct randomStruct
   {
    // some functions and variables here
   }
}

Class B
{
// and here I need to call my randomStruct from class A
  A::randomStruct myRandomStruct;  // use the public definition in A
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM