簡體   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