I am using data.h
file which have the following code
#ifndef __DATA_h_INCLUDED__
#define __DATA_h_INCLUDED__
#include "string"
struct data {
std::string location="";
int year = 0, month = 0;
data();
data(std::string location, int year, int month);
};
#endif
and the data.cpp
file looks like this
#include "data.h"
#include "string"
using namespace std;
data::data() {
//initialize the data members (location,year,month)
}
data::data(std::string loc, int year, int month) {
//initialize the data members (location,year,month)
}
in some other .cpp file how can i get these values and initialize these values.
node.h
struct Node {
data d;
Node(std::string id, int year, int month);
};
node.cpp
Node::Node(string id, int year, int month){
// here i want to initialize 'data'
}
print.cpp
Node* node;
cout<<node->data->location;