![]() |
Pointer return type,.. ???
I am writing a class employ with the following private data members
:
fName. // An object of type char array used to hold the Employee's first name Now the problem is how do i use the following accessors to acesses the private memebers: :
1. char* getFName() for the fName memberThe regular one i understand ,. the porblem are the ones with the pionter return type,.. The is bascially an abstract class and couple of classes would be dervied from it. Thank u,.. |
:
char* getFName() |
:
TheName then becomes a pointer to the first element of fName, and you can use it as an array as well, by going TheName[i] in all the standard ways. |
:
return &fName |
is it possible to send a character array via function with out telling the size of the array like this:
:
//Prototype |
You can pass the size as another parameter, and refer to the parameter. Hardcoding it like you have is a bad idea. Have you considered using std::string?
|
The question specifialy asks for the C Strings,.. I would have perfered string too,.. lol
|
Why exactly, would you need to have the size of the array for a copy operation? That said:
:
int size = 0;And Quote:
|
This is the Entire Question
:
Begin with creating the Employee class.Question: With the stated Functions and datatypes is it possible to create a list? Or do i have to use somthing else like Structs,....?? |
Sure.
:
std::list<Employee*> employees;Note: If you're supposed to write your own list class, have fun! (sucks for you!) |
| All times are GMT -5. The time now is 6:45 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC