I just switched from Python to C++. This is a practice I did for struct
. There's always an error 'incomplete type is not allowed' if I don't directly use struct at the source file.
I have review many answers at stack overflow and tried to add typedef
in header or remove struct at std::vector<double> timesteps(struct temporal_info time)
, but none of them work.
Here's my dmdbase.h
#ifndef dmdbase
#define dmdbase
#include <iostream>
#include <vector>
class DMDBase
{
public:
struct temporal_info
{
double t0;
int trend;
double dt;
};
std::vector<double> timesteps(struct temporal_info time);
};
#endif
Here's my dmdbase.cpp
using namespace std;
std::vector<double> timesteps(struct temporal_info time)
{
std::vector<double> time_map;
double final = time.trend + time.dt;
for (double t = time.t0; t < final; t += time.dt)
{
time_map.push_back(t);
}
return time_map;
}