As others have mentioned, you should be preventing the copying of your Socket object, which can be done by adding:
private:
Socket(const Socket &){}
Socket & operator=(const Socket &){return *this;}
Then to actually connect, you could do so after default construction with the implementation of a connect method, which could be called explicitly, or by the remaining constructor:
bool Socket::connect(std::string ip, int port) {
mSock = socket(AF_INET, SOCK_STREAM, 0);
if (mSock == INVALID_SOCKET)
return false;
SOCKADDR_IN addr = {0};
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr.s_addr = inet_addr(ip.c_str());
if (connect(mSock, reinterpret_cast<SOCKADDR*>(&addr), sizeof(addr))
== SOCKET_ERROR)
return false;
std::cout << mSock << " connected" << std::endl;
return true;
}
Socket::Socket(std::string ip, int port) {
if (!connect(ip, port))
throw std::runtime_error("socket()");
}