Class homework: cannot use strings.

How do I declare a function that passes me a cstring? char[5] for example.
I need it to explicit a private member of a class.

class Customers{
private:
  caName[kiArraySize]; //kiArraySize is 30
public:
  //this is what I need help for
  char[] passName(Customers);
};

char[] Customers::passName(Customers c){
   return c.caName;
}

void RandomFunction(){

cout << Customers.passName;
}

I cannot use string, homework. How can I make it? Thank you

I think your function is flawed..passname should be returning or updating its member data not another object's member data. It would make more sense to have this.

class Customers{
private:
  char caName[kiArraySize]; //kiArraySize is 30
public:
  //this is what I need help for
  const char* passName() const;
};

const char* Customers::passName() const {
   return caName;
}

void RandomFunction(Customers c){

cout << c.passName();
}

>>char[] Customers::passName(Customers c){

It is customary to code that using *, not [], as shown in the previous ^^^ post.

>>char[] Customers::passName(Customers c){

It is customary to code that using *, not [], as shown in the previous ^^^ post.

Damn it.... I always make dumb questions XD Thank you guys, really.

There's only dumb answers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.