类型传递/更改
public abstract class ASTNode3 extends ASTNode { ASTNode child1; ASTNode child2; ASTNode child3; public ASTNode3(ASTNode c1, ASTNode c2, ASTNode c3) { child1 = c1; child2 = c2; child3 = c3; } public ASTNode getChild1() { return child1; } public ASTNode getChild2() { return child2; } public ASTNode getChild3() { return child3; } } public class IRProc extends ASTNode3 { public IRProc (String p, Vector v, IRCmdSeq cmds) { super(p,v,cmds); }
我扩展了 ASTNode,如下所示,但是当我尝试传入 Vector 和 String 作为参数时,我不断收到错误。如何在不影响节点的情况下传递这些值。我正在考虑创建一个处理该类型的中间类,但我不知道该怎么做。
public abstract class ASTNode3 extends ASTNode { ASTNode child1; ASTNode child2; ASTNode child3; public ASTNode3(ASTNode c1, ASTNode c2, ASTNode c3) { child1 = c1; child2 = c2; child3 = c3; } public ASTNode getChild1() { return child1; } public ASTNode getChild2() { return child2; } public ASTNode getChild3() { return child3; } } public class IRProc extends ASTNode3 { public IRProc (String p, Vector v, IRCmdSeq cmds) { super(p,v,cmds); }
I extended the ASTNode as shown below, but when i try to pass in a Vector and a String as arguments I keep getting errors. How can I pass in these values without affecting the node. I was thinking of creating an intermediate class that handle the type, but i don't know how to.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在该行中,
您尝试使用参数
String p, Vector v, IRCmdSeq cmds
调用构造函数ASTNode3(ASTNode c1, ASTNode c2, ASTNode c3)
。这不匹配。您必须创建
ASTNode
实例才能调用super()
。如何执行此操作取决于您想要做什么。也许您应该解释一下p
、v
和cmds
实际包含哪些信息。In the line
you try to call the constructor
ASTNode3(ASTNode c1, ASTNode c2, ASTNode c3)
with the argumentsString p, Vector v, IRCmdSeq cmds
. This doesn't match.You have to create instances of
ASTNode
to callsuper()
. How you do this depends on what you want to do. Perhaps you should explain what kind of informationp
,v
andcmds
actually contain.