tags:

views:

97

answers:

3

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

A: 

The definition for data goes in data.h

class Data { ... }

and include the file in analysis.cpp

#include "data.h"

and pass it as a reference

class Analysys { bool Analyse(Data &data); }

David Sykes
Note that you need to declare the class in analysis.h, "class Data;", to be able to use it in signatures.
dutt
A: 

You can create new structure in which you can store results from your class and use it to send your results over your classes. For example:

Struct Result {
    bool dataResult;
    bool analisysResult;
};
kogut
+1  A: 

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.

Tony