Question
Hi! Can anyoane help with a little issue that I have. Client Class represents the clients of the program that own shares (Actiune Class) how
Hi!
Can anyoane help with a little issue that I have.
Client Class represents the clients of the program that own shares (Actiune Class) how could I use the ofstream function with the operator >> to write clients in a txt file called Clients.txt? at the moment I can write a client but will be write correctly only the variables "nume, sold, Actiuni (which represents the number of shares) but not the vector classActiuni, which represent the client's shares Thanks in advance, if the question is not clear please ask me, I will try to reformulate.
friend ofstream& operator << (ofstream& ofs, const Client& cl) { ofs << cl.nume << " "; ofs << cl.sold << " "; ofs << cl.Actiuni << endl; ofs << cl.vectorActiuni << endl; return ofs; }
friend istream& operator>>(istream& in, Client& s) { cout << "Da nume: "; in >> s.nume; cout << "Soldul: "; in >> s.sold; cout << "are: "; in >> s.Actiuni;
cout << " actiuni." << endl;
if (s.vectorActiuni) { delete[] s.vectorActiuni; } s.vectorActiuni = new Actiune*[s.Actiuni]; for (int i = 0; i < s.Actiuni-1; i++) { cout << "Actiunile sunt: " << endl; Actiune a1; in >> a1;
} return in; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started