搭建数据结构方面的问题 #49
Answered
by
RicoloveFeng
ningninger
asked this question in
Q&A
-
|
当我使用c++的面向对象来设计信息管理系统的时候,我定义了一个类叫goods,并将goods的所有数据(包括id,name)放入它的private时,发现我文件的读入和输出需要把它列为友元。之后我定义了一个类数组,这样每次在我使用函数去修改这个类数组时,我必须都要把我的函数变成友元函数,那么我的函数都会变成友元函数,可是不是说尽量不要使用友元函数,因为它破坏了数据的封装么 |
Beta Was this translation helpful? Give feedback.
Answered by
RicoloveFeng
Feb 22, 2022
Replies: 1 comment 2 replies
-
|
你可以用get/set函数来读写你的goods,再把中间数据拿去做文件读写。 |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
RicoloveFeng
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
你可以用get/set函数来读写你的goods,再把中间数据拿去做文件读写。