C++:使用一个函数的输出作为带有函数原型的头文件中另一个函数的参数
C++: using one function's output as a parameter for another one in the header file with function prototypes
我不确定如何使用函数averating(…)的返回值作为下一个函数preferenceFactor(…)来进行除法。如有任何帮助,不胜感激。
/**
*Calculates the average rating of movies for a particular genre by the user 'u'
*Calculated by: (#of movies rated in one genre)/(sum of all the ratings)
*
*@param movies is the number of movies in one genre
*@param sumRatings is sum of the ratings by the user
*@return the average rating
*/
virtual double averageRating(int numberOfMovies, double sumOfRatings) {
return (numberOfMovies/sumOfRatings);
}
/**
*Calculates the user's "preference factor".
*Calculated by: (averageRating/generalAverageRating)
*
*@param sumOfRatings average rating for the same movie by all users
*@return the user's preference factor
*/
virtual double preferenceFactor(double generalAverageRating) {
return ("averageRating's output(?) divided by generalAverageRating")
}
不能使用averating()作为preferanceFactor()的参数,以便preferanceFactor有2个参数吗?
virtual double preferanceFactor(double avrRating, double genAvrRating);
,然后当调用prefFact时,你传递的平均值(x,y)作为第一个参数?这可以接受吗?
或者你可以只传递3个参数(2个作为平均参数,第三个是genAvRate。
virtual double preferenceFactor(int numberOfMovies, double sumOfRatings, double generalAverageRating) {
return averageRating(numberOfMovies, sumOfRatings)/generalAverageRating;
}
,然后在prefFact函数u调用平均()前两个参数?
相关文章:
- 函数如何通知用户它基于函数原型抛出异常?
- 在函数中拥有函数原型的目的是什么?
- 什么..(省略号)作为函数原型中唯一的函数参数,C++?
- 是否可以使用 libclang python 解析 cpp 文件中没有标头的函数原型
- 有没有办法在C++编译时更改函数原型?
- 省略函数原型中的返回类型
- 如何使用 "using" 关键字定义函数原型/签名
- 函数原型未初始化的局部变量
- 如何创建函数原型命名空间
- 标准库头文件函数原型的实现是如何用 c++ 编写的?
- 为什么这种类型的函数原型会引发错误?
- 函数指针类型不能用于函数原型
- 了解此函数原型
- 将字符串向量传递给函数和函数原型问题 c++
- 函数原型范围的有趣用法
- 为什么这不起作用(C++函数原型)
- 将数组传递到函数会在函数原型声明中出现错误
- 在头文件中的函数原型中获取指针数组:函数声明为 void
- 类/成员函数中的函数原型
- 函数原型中的字符串初始化