Introduction
I'm really new in C++. I've started read some books and search some stuff in Internet. But my main problem is debug C++ code and the basics.
So, I want create a new class, called ClientTcp. If create the object with no arguments, the IP and the Port shall be standard (127.0.0.1:8000).
I've read this question Constructor Overloading in C++.
So I created this code:
ClientTcp.h file.
class ClientTcp{
public:
// non arguments, create loopback connection
ClientTcp();
ClientTcp(std::string, std::string);
virtual ~ClientTcp();
protected:
private:
std::string ip_, port_;
};
ClientTcp.cpp file
#include "ClientTcp.h"
ClientTcp::ClientTcp(){
ip_ = "127.0.0.1";
port_ = "8000";
}
ClientTcp::ClientTcp(std::string ip, std::string port){
ip_.assign(ip);
port_.assign(port);
}
ClientTcp::~ClientTcp(){
//dtor
}
Main.cpp file
#include <string>
#include <iostream>
#include "json.hpp"
#include <ClientTcp.h>
std::string cip, cport;
cip = "127.0.0.1";
cport = "9510";
ClientTcp c(cip, cport);
Problem It seems perfect, but I have a ridiculous error that I can't understand.
error: expected ‘)’ before ‘,’ token|
Line: This error is present in ClientTcp(string, string);
line.