How much to do in a contructor
I am very new to C++ and am trying to learn how most people do things.
I have made a class and am wondering how much is too much in a constructor and what is considered bad practice. What I want to do with this class is (just for now) create a socket ready to listen on a server.
Here is how I am currently doing it.
I also don't know if it is typically a good idea to "return" out of a constructor.
server_socket(short int port)
fport = port;
fsock = 0;
memset(&faddr, 0, sizeof(struct sockaddr_in));
/* Create the socket */
//After I create the class I also call isvalid() in the function as well
return (fsock != -1);
bool send(const char *);
int recv(char *);
short int fport;
struct sockaddr_in faddr;
bool bind(const int port);
bool accept(int *fsock);
I'm all ears right now because I am trying to write code a standard C++ programmer typically would. Moving from C to C++ has quite a few differences to say the least. Still haven't moved into <string> yet.