我有一个类来读取数据(data.h& data.cpp),一个类用于分析数据(analysis.h& analysis.cpp),另一个类基于两个以前的类进行计算(计算。 h& calculation.cpp)。 我不知道如何将结果从数据类传递给分析类,以后从两者传递到计算类。我试图把data.h放入analysis.cpp但它没有成功谢谢你的时间
I have one class to read data (data.h & data.cpp), one class to analysis data (analysis.h & analysis.cpp) and another one to do calculation based on two previous classes (calculation.h & calculation.cpp). I wonder how can I pass the results from data class to analysis class and later on from both of them to calculation class. I tried to put the data.h into analysis.cpp but it didn't work out Thank you for your time
推荐答案在calculate.cpp中,您可以#include data.h和analysis.h,然后使用数据函数检索数据,将结果传递给分析,然后将这些结果计算。
In calculation.cpp, you'd #include data.h and analysis.h, then use data functions to retrieve the data, passing the result(s) to analysis, then those results to calculation.
这可以归结为大致像... ...
This boils down to something roughly like...
#include "data.h" #include "analysis.h" Data data; Analysis analysis; while (data.get()) analysis.process_more(data); Calculation calculation(analysis); calculation.report();换句话说,类类型的对象是结果。
In other words, objects of the class types ARE the results.
更多推荐
C ++:如何将结果从一个类传递到另一个类?
发布评论