0

I know that there are a lot of tutorials and also there are a lot of solutions in Stack overflow itself but I don't really get a concept of constructors - what is the purpose of writing them if compiling software will create one of it's own? My another question is if they are necessary how to write a proper one basing on my header file for c++ program:

#pragma once
class customers
{
public:
    char firstname[50];
    char lastname[50];
    char address[64];
    char password[50];
    int age;
    char email[100];
    void Add_customer();
    customers change_customer(customers);
    void remove_customer(customers*[], customers);
    void search_customer(customers, customers[]);
    char getName();
    void setName(char[]);


};

What should I avoid with writing the constructor and how to write one - I know that they allow to initialise variables from header written classes but this is all what I understand - so please use that header given above as example. Thank you for your time if you want to help me.

  • side note: use `std::string` for text, not `char[]` – Fureeish Nov 18 '18 at 14:08
  • 1
    Any good C++ book will have a full explanation of what constructors are, and why they're needed, and when. stackoverflow.com is not a tutorial site and is not a substitute for a good C++ book. A complete answer cannot be given in one or two short paragraphs on stackoverlfow.com – Sam Varshavchik Nov 18 '18 at 14:12
  • So do you have any good propositions of books or websites where I can find answers? I just want to know how to do that that's all – AnotherNewbie Nov 18 '18 at 14:42
  • it also looks like you should separate the element `customer` and the collection `customers`. – Thomas Nov 18 '18 at 14:43
  • @AnotherNewbie see: https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list – TrebledJ Nov 18 '18 at 15:06

0 Answers0