I have given only some part of the code related to my problem. I have problem while compliation. I have the problem in the constructor of the class RMstore. i Get the following compilation error

rmremote_server.cpp: In function `int main()':
rmremote_server.cpp:196: error: no matching function for call to `RMStore::RMStore(std::string)'
rmremote_server.cpp:17: note: candidates are: RMStore::RMStore(const RMStore&)
rmremote_server.cpp:26: note: RMStore::RMStore(std::string&)

class RMStore
	string command;
	string result;
	string error;
	bool status;


	RMStore(string comm = "");
	inline string getCommand();
	inline string getResult();
	bool executeCommand();

RMStore::RMStore(string comm):command(comm)
	result = "";
	error = "";

string RMServer::getData()
	return data;

int main()
	string command;
	command = "ls -l /usr/local/dataware | grep ^l";

	RMServer *server = new RMServer();

	if(server->openConn() > 0)
		while(server->acceptConn() > 0)
			if(server->recvData() > 0)
				RMStore *R = new RMStore(server->getData());
				//RMStore *R = new RMStore(command);
				delete R;


I was under the impression that, even tough we pass a string, the called function will take it in a ref and the compiler will not complain.

also if i use RMStore *R = new RMStore(command); instead of RMStore *R = new RMStore(server->getData()); i donn get any errors.

am i missing something here? please help?

Visual C++ 9.0 compiler resolves this situation. Obvious workaround with your compiler: define explicitly default RMStore constructor (an all others):

class RMStore {
public: // Place public part at the beginning
    // You forgot initialize status member
    explicit RMStore(const char* pcmd):
    explicit RMStore(const std::string& cmd):
    const std::string& getCommand() const {
         return command;
    std::string command;
    std::string result;
    // No need to initialize empty string members
    // explicitly: string default constructors do it.

Use explicit keyword in that case (in constructors with the single parameter). Without explicit the RMStore::RMStore(type) constructor defines implicit conversion from type to RMStore. As usually it's not a desired effect.

You declared member function prototypes as inline. It's a senseless declaration because:
1. Where is that member function body to substitute it inline?
2. All member function definitions (with bodies) in a class definition are inline by default.

This article has been dead for over six months. Start a new discussion instead.