【问题标题】:How to get access to struct in one class from another?如何从另一个类中访问结构?
【发布时间】:2017-10-29 10:47:30
【问题描述】:

如何访问 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
}

这只是代码示例

【问题讨论】:

  • A::randomstruct??
  • 您不能“调用结构”。请贴出真实代码

标签: c++


【解决方案1】:

如果你打电话意味着使用这可能是一个解决方案

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
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-06
    相关资源
    最近更新 更多