Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 聚合类是否可以相互使用';功能?_C++_Oop - Fatal编程技术网

C++ 聚合类是否可以相互使用';功能?

C++ 聚合类是否可以相互使用';功能?,c++,oop,C++,Oop,我想添加一个新的类名Bill,这个类为客户对象生成一个Bill。但是,我在类customer 我想在类Bill中使用这个函数。聚合是否可能实现这一点?(我不想继承,只想要Bill类中的特定函数)一个代码片段值千言万语。为什么Bill会有一个displayCustomerDetails()函数?有一个displaydestails()函数是有意义的,但是为什么要显示客户详细信息呢?Bill和Customer之间不存在某种形式的关联吗?因此,Bill中的displaydestails()函数将调用B

我想添加一个新的类名
Bill
,这个类为
客户对象生成一个Bill
。但是,我在类
customer

我想在类
Bill
中使用这个函数。聚合是否可能实现这一点?(我不想继承,只想要Bill类中的特定函数)

一个代码片段值千言万语。为什么
Bill
会有一个displayCustomerDetails()函数?有一个
displaydestails()
函数是有意义的,但是为什么要显示客户详细信息呢?
Bill
Customer
之间不存在某种形式的关联吗?因此,
Bill
中的
displaydestails()
函数将调用
Bill.customer.displaydestails()
?我是OOP新手,我们还没有研究实现,只是研究了UML图。因此,我想知道如何在Bill类中访问customer的某个函数,即displayCustomerDetails()?我在问这种方法的关系@JHIF
Bill
可以访问
Customer
实例(在本例中应该是这样的——拥有
Bill
没有意义,但是没有
Customer
——因此这是一个依赖项[聚合?]),在代码中,您可以在
Customer
实例上调用
displayDetails
,假设函数是公共的,它应该是公共的。首先尝试为这些类编写代码可能会有所帮助。试图在没有代码的情况下学习OOP可能会使理解实际发生的事情变得困难。@JHH明白了。谢谢:)