我是 C++ 新手,我有疑问。
我有如下代码:
void FlowState::closeFile() {
if (outfile) {
//from here
struct timeval times[2];
times[0] = myflow.tstart;
times[1] = myflow.tstart;
outfile->flush();
outfile->close();
//to here
}
}
我对所选部分有疑问。为什么我需要这个?它是如何工作的?
这可能会有所帮助:
class FlowState {
public:
string flowid;
class Streamdemux &demux;
Flow myflow;
// ...
FlowState(class Streamdemux &demux_, const Flow &flow_,
u_int32_t isn_, bool tcp);
virtual ~FlowState();
// ...
};
和:
class Flow: public flowAddr {
public:
int32_t vlan;
struct timeval tstart;
struct timeval tlast;
uint64_t packet_count;
uint64_t connection_count;
string fileNameTemplate;
Flow() :
vlan(), tstart(), tlast(), packet_count(), connection_count() {
fileNameTemplate = "%S:%s-%D:%d"; //brakuje ID połączenia
}
Flow(const flowAddr &flowAddr_, uint16_t vlan_,
const struct timeval &t1, const struct timeval &t2,
uint64_t connection_count_) :
flowAddr(flowAddr_), vlan(vlan_), tstart(t1), tlast(t2), packet_count(
0), connection_count(connection_count_) {
fileNameTemplate = "%S:%s-%D:%d";
}
virtual ~Flow() {
}
};