Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions