Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I am new in c++ so please excuse me is this is basic for you. How can I write an object of class Client

Hello, I am new in c++ so please excuse me is this is basic for you. How can I write an object of class Client in a txt file? the variable vectorActiuni store shares(objects of class Actiune). (Actiune** vectorActiuni). with the code that I have right now the output in the txt file look like this:

client1 1000 1 CDCDCDCD (this should ve been an object of class Actiune)

this is my code:

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; i++) { cout << "Actiunile sunt: " << endl; Actiune a1; in >> a1; }

friend ofstream& operator << (ofstream& ofs, const Client& cl) {

ofs << cl.nume << " "; ofs << cl.sold << " "; ofs << cl.Actiuni << endl; for (int i = 0; i < cl.Actiuni; i++) ofs << cl.vectorActiuni[i] << endl; return ofs; }

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_2

Step: 3

blur-text-image_3

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 Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions