Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问graph.hpp“关于赋值函数的bug” #21

Open
wileney opened this issue May 13, 2024 · 1 comment
Open

请问graph.hpp“关于赋值函数的bug” #21

wileney opened this issue May 13, 2024 · 1 comment

Comments

@wileney
Copy link

wileney commented May 13, 2024

这个“赋值函数”指的具体是什么?graph.hpp并没有(显式)定义自己的赋值函数啊。

@bw-S0L
Copy link
Collaborator

bw-S0L commented May 13, 2024

1、bug就是一个Node存了一份指向graph的指针,如果使用默认的赋值函数,则新graph的Node内的指针是指向旧的graph
2、Node存了一份指向graph的指针,这样的设计,是C语言留下来的,当时我们会使用container_of这样的操作,通过struct内的成员,计算偏移,去获得该struct对象。在C++版本,我希望保留该设计,但没有发现优雅的实现方式。
3、本lab中不需要使用Node去查找graph这个操作,我们同时只会存在并使用一个graph。如果需要,可以遍历显式地给新graph内的Node的指针修正。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants