[英]Does Solidity language has namespace?
在 Solidity 语言中,我定义了ContractA
和ContractB
。
在ContractA
内部声明结构A
并且我想在ContractB
内部访问A
。
contract ContractA {
struct A {
uint age;
string name;
}
// Some other methods and data structure
}
contract ContractB {
// how to access structure A.
}
我不想使用 Inheritance 或library
语法。
Solidity 中没有 C# 的命名空间。
如果您想在合同之间共享结构,请声明一个库。
library Structs {
struct AnyName {
uint256 id;
}
}
contract ContractA {
Structs.AnyName go;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.