I am facing one issue while passing file object using structure and the code is
#include <iostream>
#include<fstream>
using namespace std;
typedef struct abc
{
ofstream &t;
}stabc;
class dc
{
public:
static void fun(stabc *ad);
static stabc ab;
};
int main()
{
ofstream str;
str.open("hello.csv",ios::app);
str<<"hellllooo"<<endl;
dc d;
d.ab.t=str;
dc::fun(&d.ab);
cout << "Hello world!" << endl;
return 0;
}
void dc::fun(stabc *ad)
{
ofstream& st=ad->t;
st<<"kikiki"<<endl;
}
It gives uninitialized reference member abc::t. Please tell me where i am wrong?