How to initialize object in a polymorphic way ?

Hi I need to create polymorphism and initialize the data in the following way:
I need to save new customer detail in files (text)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
#include <iostream>
#include<fstream>
#include <cstring>
#include <string>
using namespace std;
class Name
{
	char* fname;
	char* Lname;
public:
	Name()
	{
		fname = new char[50];
		Lname = new char[50];
	}
	Name(char* fN, char* IN)
	{
		fname = new char[50];
		Lname = new char[50];
		fname = fN;
		Lname = IN;
	}
	~Name()
	{
		delete [] fname;
		fname = NULL;
		delete [] Lname;
		Lname = NULL;
	}
	void setfn(char* fN)
	{
		fname = fN;
	}
	void setIn(char* IN)
	{		Lname = IN;
	}
	char * getfn()
	{return fname;
	}
	char * getIn()
	{		return Lname;
	}
	Name(const Name & obj)
	{		
		int len1 = 0;
		for (int i = 0; obj.fname[i]!='\0'; i++)
		{
			len1++;
		}
		fname = new char[len1 + 1];
		int i=0;
		for ( ; i < len1; i++)
		{
			fname[i] = obj.fname[i];
		}
		fname[i] = '\0';
		i = 0; len1 = 0;
		for (int i=0; obj.Lname[i] != '\0'; i++)
		{
			len1++;
		}
		Lname = new char[len1 + 1];		
		for (; i < len1; i++)
		{
			Lname[i] = obj.Lname[i];
		}
		Lname[i] = '\0';
	}
	friend ostream& operator <<(ostream& out, const Name& n);	
};
ostream& operator <<(ostream& out, const Name& n)
{
	out << n.fname << " " << n.Lname << endl;
	return out;
}
class Date
{	int day, month, year;
public:
	Date()
	{
		day = 0; month = 0; year = 0;
	}
	Date(int d, int m, int y)
	{
		if (m>0 && m<13)
		{
			month = m;
			if (m==1 || m==3 ||m==5 ||m==7||m==8||m==10||m==12)
			{
				if (d>0 &&d<32)
				{
					day = d;
				}
				else
				{
					day = 0;
				}
			}
			else if (m == 2)
			{
				if (d>0 &&d<29)
				{
					day = d;
				}
				else
				{
					day = 0;
				}
			}
			else
			{
				if (d > 0 && d < 31)
				{
					day = d;
				}
				else
				{
					day = 0;
				}
			}
		}
		else
		{
			month = 0;
		}
		year = y;
	}
	void setd(int d)
	{
		if (d>0 &&d<32)
		{
			day = d;
		}
		else
		{
			cout << "Invalid date ";
		}
	}
	void setm(int m)
	{
		if (m>0 &&m<13)
		{
			month = m;
		}
		else
		{
			cout << "Invalid month.Try again "<<endl;
		}
	}
	void sety(int y)
	{
		year = y;
	}
	int getd()
	{
		return day;
	}
	int getm()
	{
		return month;
	}
	int gety()
	{
		return year;
	}
	friend ostream& operator<<(ostream& out, const Date& d);
};
ostream& operator<<(ostream& out, const Date& d)
{
	out << d.day << "/" << d.month << "/" << d.year << endl;
	return out;
}
class mTime
{
	int hour, min, sec;
public:
	mTime()
	{
		hour = 0; min = 0; sec = 0;
	}
	mTime(int h, int m, int s)//Validation?
	{
		hour = h;
		min = m;
		sec = s;
	}
	void seth(int h)
	{
		if (h >= 0 && h < 24)
		{
			hour = h;
		}
		else
		{
			cout << "Invalid hour ";
		}
	}
	void setm(int m)
	{
		if (m>=0 && m<61)
		{
			min = m;
		}
		else
		{
			cout << "Invalid minute ";
		}
	}
	void sets(int s)
	{
		if (s>=0 && s<61)
		{
			sec = s;
		}
		else
		{
			cout << "Invalid seconds ";
		}
	}
	int geth()
	{
		return hour;
	}
	int getm()
	{
		return min;
	}
	int gets()
	{
		return sec;
	}
	friend ostream& operator<<(ostream& out, const mTime& m1);
};
ostream& operator<<(ostream& out, const mTime& m1)
{
	out << m1.hour << ":" << m1.min << ":" << m1.sec << endl;
	return out;
}
class Service
{
	char* source, * destination;
	float distance;
	Date bookingDate;
	mTime bookingtime;
	bool status;
	float fuelrate;
	int cID,dID,vID;
};
class Ride :public Service
{
	int noofPassengers;
	char* ridetype;
	float driverranking;
	float vehicleranking;
};
class Deliver :public Service
{
	float goodsWeight;
	char* goodstype;
};
class Person
{
	Name pName;
	Date DOB;
	int age,Nid;
public:
	Person()
	{	age = 0;
		Nid = 0;
	}
	Person(Name n, Date d, int a, int id)
	{
		pName = n;
		DOB = d;
		age = a;
		Nid = id;
	}
	Person(const Person& obj)
	{
		DOB = obj.DOB;
		pName = obj.pName;
		age = obj.age;
		Nid = obj.Nid;
	}
	void setN(Name n)
	{
		pName = n;
	}
	void setdob(Date d)
	{
		DOB = d;
	}
	void setage(int a)
	{
		age = a;
	}
	void setid(int id)
	{
		Nid = id;
	}
	int getage()
	{
		return age;
	}
	int getid()
	{
		return Nid;
	}
	Name getn()
	{
		return pName;
	}
	Date getdob()
	{
		return DOB;
	}
	friend ostream& operator<<(ostream out, const Person& p1);
};
ostream& operator<<(ostream out, const Person& p1)
{
	cout << "Name of Person is " << p1.pName << endl << "Date of birth is " << p1.DOB << endl << "Age is: " << p1.age << endl << "ID is " << p1.Nid<<endl;
}
class Customer :public Person
{
	int cId;
	Service** bookingHistory;
public:
	Customer()
	{	cId = 0;
		bookingHistory = 0;
	}
	Customer(Name p, Date dob, int a, int id, int cid, Service** bH) :Person(p, dob, a, id)
	{
		cId = cid;
		bookingHistory = bH;
	}
	~Customer()
	{	
	}
	void setcusid(int a)
	{
		cId = a;
	}
	void setbookinghis(Service** bh)
	{
		bookingHistory = bh;
	}
	 int getcusid()
	{
		return cId;
	}
	Service **getbookinghis()
	{
		return bookingHistory;
	}
	Customer(const Customer& b1)
	{
		cId = b1.cId;
		bookingHistory = b1.bookingHistory;
	}
	friend ostream& operator <<(ostream& out, const Customer& );
};
ostream& operator <<(ostream& out, const Customer& b1) // printing history missing
{
	cout << "Customer ID is: " << b1.cId;
	
}

int main()
{	
	Service sr1()
	Service**  ser;
	 ser = new Service[2] { {2,5}, {3,6} };
 	Person *aptr; 
    Customer cust ("Ali", Date(23,05,2001),1,1,1,)); 
	cout << cust.getcusid();
	system("pause");
}
Last edited on
What is the question or problem ?

Is this homework where you have to do things in a last-century kind of way?
Remaining Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
class Driver :public Person
{
	int dId,nooflicences,experience,status;
	float overallRanking, salary;
	char** Licenselist;
	Service** serviceHistory;
public:
	Driver()
	{
		dId = 0; nooflicences = 0; experience = 0; status = 0;
		overallRanking = 0.0; salary = 0.0;
		Licenselist = 0;
		serviceHistory = 0;
	}
	Driver(Name p, Date dob, int a, int id, int d, int n, int ex, int s, float r, float sal,char**A,Service**sh) :Person(p, dob, a, id)
	{
		dId = d; nooflicences = n; experience = ex; status = s;
		overallRanking = r; salary = sal;
		Licenselist = A;
		serviceHistory = sh;
	}
	~Driver()	//delete servicehis
	{
		for (int i = 0; i < nooflicences; i++)
		{
			delete[]Licenselist;
		}

	}
	void seti(int a, int b, int c, int d)
	{
		dId = a;
		nooflicences = b;
		experience = c;
		status = d;
	}
	void setfl(float r, float s)
	{
		overallRanking = r;
		salary = s;
	}
	void setpo(char** l, Service** sh)
	{
		Licenselist = l;
		serviceHistory = sh;
	}
	int getdid()
	{
		return dId;
	}
	int getnumliscense()
	{
		return nooflicences;
	}
	int getexp()
	{
		return experience;
	}
	int getstat()
	{
		return status;
	}
	float getrank()
	{
		return overallRanking;
	}
	float getsal()
	{
		return salary;
	}
	char** getlislist()
	{
		return Licenselist;
	}
	Service** getservhis()
	{
		return serviceHistory;
	}
	Driver(const Driver& d1)
	{
		dId = d1.dId; nooflicences = d1.nooflicences; experience = d1.experience; status = d1.status;
		overallRanking = d1.overallRanking; salary = d1.salary;
		Licenselist = d1.Licenselist;
		serviceHistory = d1.serviceHistory;
	}
	friend ostream& operator<<(ostream& out, const Driver&);
};
ostream& operator<<(ostream& out, const Driver&d1)	//printing service history??
{
	cout << "The id of driver is " << d1.dId << endl << "The number of licenses are: " << d1.nooflicences << endl;
	cout << "The experience of driver is " << d1.experience << endl << "The status of driver is " << d1.status << endl;
	cout << "The Overall Ranking of driver is " << d1.overallRanking << endl << "The Salaryof driver is: " << d1.salary << endl;
	cout << "List of licenses: "<<endl;
	for (int i = 0; i < d1.nooflicences; i++)
	{
		for (int j = 0; d1.Licenselist[i][j]!='\0'; j++)
		{
			cout << d1.Licenselist[i][j];
		}
		cout << endl;
	}
}
class feature
{
	int fId;
	char* description;
	float cost;
public:
	feature()
	{
		fId = 0;
		cost = 0;
		description = new char;
	}
	feature(int f, char* A, float c)
	{
		fId = f;
		description= new char;
		description = A;
		cost = c;
	}
	void setfeature(int id, char* d, float c)
	{
		fId = id;
		description = new char;
		description = d;
		cost = c;
	}
	int getfeatid()
	{
		return fId;
	}
	char* getdescrip()
	{
		return description;
	}
	float getcost()
	{
		return cost;
	}
};
class Vehicle
{
	int vId, registrationNo;
	float avgMileage, overallRanking;
	char* Licensetype, * fueltype;
	bool status;
	Date manufacturingDate;
	feature* list;
	Service** serviceHistory;
public:
};


First problem is how to initialize service**.

And Customer class with above structure.

And second question is how to store Customer detail
In a text file using Stream.

Yes this is an very old way.

I know ,in current features, we deal vector and string these days
But unfortunately , our teachers are still following old approaches and processes.

What can we do is except to submit in this way.

Sorry, if you can help then please share your contribution.
Thank you
Last edited on
But unfortunately , our teachers are still following old approaches and processes.
What can we do is except to submit in this way.

Yes there is not much you can do. Just grit your teeth and do his/her way.

I would start fixing the Name class.
Your Name ctor needs fixing, currently it creates a memory leak.
1
2
fname = fN;
Lname = IN;

This overrides the original address of the allocated pointers.
You need to implement the copy assignment operator. Is there a reason why the length for the names is 50? Normally you would use the length of the input string.

BTW: what compiler / IDE do you use?
You can help us help you:
Please learn to use code tags, they make reading and commenting on source code MUCH easier.

How to use code tags: http://www.cplusplus.com/articles/jEywvCM9/

There are other tags available.

How to use tags: http://www.cplusplus.com/articles/z13hAqkS/

HINT: you can edit your post and add code tags.

Some formatting & indentation would not hurt either

There are various issues - especially re c-style string arrays. As a first refactor, consider:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
#include <iostream>
#include <cstdio>
#include <cstring>

constexpr size_t MAX_STR { 50 };

class Name {
	char* fname {};
	char* Lname {};

public:
	Name() : fname(new char[MAX_STR]), Lname(new char[MAX_STR]) {}

	Name(const char *fN, const char *IN) : Name() {
		setfn(fN);
		setIn(IN);
	}

	~Name() {
		delete[] fname;
		delete[] Lname;
	}

	Name(const Name& obj) : Name(obj.fname, obj.Lname) {}

	Name& operator=(const Name& rhs) {
		setfn(rhs.fname);
		setfn(rhs.Lname);
	}

	void setfn(const char* fN) {
		std::snprintf(fname, MAX_STR, "%s", fN);
	}

	void setIn(const char* IN) {
		std::snprintf(Lname, MAX_STR, "%s", IN);
	}

	char* getfn() const {
		return fname;
	}

	char* getIn() const {
		return Lname;
	}

	friend std::ostream& operator<<(std::ostream& out, const Name& n);
};

std::ostream& operator<<(std::ostream& out, const Name& n) {
	return out << n.fname << ' ' << n.Lname;
}

class Date {
	unsigned day {}, month {}, year {};

public:
	Date() {}

	Date(unsigned d, unsigned m, unsigned y) : year(y) {
		if (m > 0 && m < 13) {
			month = m;

			if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12)
				day = (d > 0 && d < 32) ? d : 0;
			else if (m == 2)
				day = (d > 0 && d < 29) ? d : 0;
			else
				day = (d > 0 && d < 31) ? d : 0;
		} else
			month = 0;
	}

	bool setd(unsigned d) {
		if (d > 0 && d < 32) {
			day = d;
			return true;
		}

		return false;
	}

	bool setm(unsigned m) {
		if (m > 0 && m < 13) {
			month = m;
			return true;
		}

		return false;
	}

	void sety(unsigned y) {
		year = y;
	}

	unsigned getd() const {
		return day;
	}

	unsigned getm() const {
		return month;
	}

	unsigned gety() const {
		return year;
	}

	friend std::ostream& operator<<(std::ostream& out, const Date& d);
};

std::ostream& operator<<(std::ostream& out, const Date& d) {
	return out << d.day << '/' << d.month << '/' << d.year;
}

class mTime {
	unsigned hour {}, min {}, sec {};

public:
	mTime() {}
	mTime(unsigned h, unsigned m, unsigned s) : hour(h), min(m), sec(s) {}

	bool seth(unsigned h) {
		if (h >= 0 && h < 24) {
			hour = h;
			return true;
		}

		return false;
	}

	bool setm(unsigned m) {
		if (m >= 0 && m < 61) {
			min = m;
			return true;
		}

		return false;
	}

	bool sets(unsigned s) {
		if (s >= 0 && s < 61) {
			sec = s;
			return true;
		}

		return false;
	}

	unsigned geth() const {
		return hour;
	}

	unsigned getm() const {
		return min;
	}

	unsigned gets() const {
		return sec;
	}

	friend std::ostream& operator<<(std::ostream& out, const mTime& m1);
};

std::ostream& operator<<(std::ostream& out, const mTime& m1) {
	return out << m1.hour << ':' << m1.min << ':' << m1.sec;
}

class Service {
	char *source {}, *destination {};
	float distance {};
	Date bookingDate;
	mTime bookingtime;
	bool status {};
	float fuelrate {};
	int cID {}, dID {}, vID {};
};

class Person {
protected:
	Name pName;
	Date DOB;
	unsigned age {}, Nid {};

public:
	Person() {}

	Person(Name n, Date d, unsigned a, unsigned id) : pName(n), DOB(d), age(a), Nid(id) {}

	Person(const Person& obj) : Person(obj.pName, obj.DOB, obj.age, obj.Nid) {}

	void setN(const Name& n) {
		pName = n;
	}

	void setdob(const Date& d) {
		DOB = d;
	}

	void setage(unsigned a) {
		age = a;
	}

	void setid(unsigned id) {
		Nid = id;
	}

	unsigned getage() const {
		return age;
	}

	unsigned getid() const {
		return Nid;
	}

	Name getn() const {
		return pName;
	}

	Date getdob() const {
		return DOB;
	}

	friend std::ostream& operator<<(std::ostream out, const Person& p1);
};

std::ostream& operator<<(std::ostream out, const Person& p1) {
	return out << "Name of Person is " << p1.pName << "\nDate of birth is " << p1.DOB << "\nAge is: " << p1.age << "\nID is " << p1.Nid;
}

class Customer : public Person {
	int cId {};
	Service **bookingHistory;

public:
	using Person::Person;

	Customer() {}

	Customer(const Name& p, const Date& dob, unsigned a, unsigned id, unsigned cid, Service** bH) : Person(p, dob, a, id), cId(cid), bookingHistory(bH) {}

	~Customer() { }

	Customer(const Customer& b1) : Person(b1.pName, b1.DOB, b1.age, b1.Nid), cId(b1.cId), bookingHistory(b1.bookingHistory) {}

	void setcusid(unsigned a) {
		cId = a;
	}

	void setbookinghis(Service** bh) {
		bookingHistory = bh;
	}

	unsigned getcusid() const {
		return cId;
	}

	Service** getbookinghis() const {
		return bookingHistory;
	}

	friend std::ostream& operator <<(std::ostream& out, const Customer&);
};

std::ostream& operator <<(std::ostream& out, const Customer& b1) {
	return out << "Customer ID is: " << b1.cId;
}

int main() {
	Customer cust(Name("Ali", "Baabaa"), Date(23, 05, 2001), 1, 1, 1, nullptr);
	//Person *aptr = &cust;

	std::cout << cust.getcusid() << '\n' << cust.getn() << '\n' << cust.getdob() << '\n';
}



1
Ali Baabaa
23/5/2001

Please use code tags when posting code. Edit your original post, highlight the code and press the <> button to the right of the edit window.

In class Name, your getIn() and setIn() methods should get getLn() and setLn() since they set the last name.

Change getfn() to getFn so it's consistent with getLn

I'd create a protected init() method to allocate space for the names. setFn() and setLn() need to copy the string from the argument to meory allocated for the fname and Lname members. You can use strcpy or strncpy for this.

Your << operators need to return a value. Also, they should output to the stream parameter (out), instead of always outputting to cout. Finally, you need to pass the stream by reference.

Your getXXX() methods should all be const.

Fix the compilation errors and then start testing.

As a general comment, it's always good to write a little code and then test it. Write some more code and test it. If you try to write the whole thing and then test, you'll get overwhelmed by compiler errors and design problems.
1. One of the best ways to help us so we can help you is to post a short, self contained, correct (and hopefully compileable) example.
http://www.sscce.org/

2. Also, if this is an assignment for school post all of the assignment, not what you believe the assignment is. There may be information you missed.
Thank you all and especially seeplus for code correction.
I am using vscode c/c++,g++

Last edited on
Thank you for using code tags, and thank you for showing us all of what the assignment is. Doing this really does help. :)
My work is imcomplete. My source code file was too long to accept in single post so i code in my first post and the remaining in second post.

I need to store in file stream.

If anyone can correct my full code then it would be appreciated.

With a program of this complexity/size, IMO it is important that first a program design is done. Once that is completed, then the various parts (classes etc) can then be coded and tested before coding the next part. Compile frequently and test often. Only move on to a new part when the previous compiles OK and tests are OK. Writing a large amount of code and then compile resulting in numerous compile issues can seem daunting. If you only add/change say max 20 lines since the last compile then you know where the error is. Similarly, if a large program does compile successfully, it is highly unlikely it will work as expected first time. Logic coding errors are a fact of a programmers life. If each part of the design is tested when it compiles, then run-time issues can much more easily be identified and corrected before moving on to the next part. If each part is tested as coded, then when all parts have been coded, compiled and tested, then testing the whole program to check that it works as required is much easier.

In this way, if there is a compile issue or a test that fails, then specific question(s) can be asked.
Last edited on
Thank you seeplus.
Last edited on
The skeleton of classes is provided below for this system, complete the implementation of all classes.
Can you provide these skeleton classes? It really helps to see what you're starting from. For example, I don't know if the classes from your original post are provided, or ones that you wrote yourself.

When doing this type of problem, I find it helpful to start with the data. How will you represent what's needed? Read the assignment carefully and start writing the data that you'll need. Don't write code, or even real declarations. Just the classes and their attributes. When you're done, read the assignment again and refine your classes. Keep repeating this process until you're convinced that your data will represent everything you need.

Along the way, you may find that you have questions. Put those together in an email to the professor, TA, other students, or whoever.


Part D lists 20 things the code should do. Each one should be a function. It might call other functions.

When the time comes, write a few functions in part D, and the test code for them in part E. Test it out. Then write some more functions in each. In this way, you will test your code a little bit at a time.

In your code and all communications, be sure to use "fare" instead of "fair." Maybe the prof will get the hint and spell the word right :).
The Service class has several member variables apart from source and destination.

In the copy constructor and operator=() member functions, you also need to deal with other variables as well as source and destination.

L37 - There is no Service constructor that just takes source and destination arguments. All the class variables need to be specified

L40/41 - don't you mean setSrc() and setDest() ?

What is the purpose of bookHistory and serviceHistory?


Well this is your code - and you're asking us....


And how can i write a function for writing in streams in this manner with each class or better approach?


What do you mean? Do you want to overload the operator<< for a class like you have for say Name class? What are trying to achieve?

Last edited on
Topic archived. No new replies allowed.