here I have an error but I don't know why it shows. This is the error:

In file included from Exploit.cc:2:0: Command.hh:35:17: error: field
 ‘_value’ has incomplete type Command.hh: In constructor
 ‘Command::Command(const char*)’: Command.hh:27:3: error: ‘_value’ was
 not declared in this scope make: *** [Exploit.o] Error 1

And this is Command.hh

class Command {
public: 
    Command(const char* exp){
        _value=exp;
        _value.append("\n");
    }
    ~Command();
    void request(int fd);
    void response(std::string res);
    const char*  getCommand();
private: 
    std::string _value;
};

Exploit.cc

typedef std::shared_ptr<Command> CommandPtr;
typedef std::list<CommandPtr> CommandQueue; 
typedef std::shared_ptr<CommandQueue> CommandQueuePtr; 

Exploit::Exploit(const char* exp, int fd2, int type2): fd(fd2), type(type2){
    commands_to_execute = make_shared<CommandQueue>();
    commands_executed = make_shared<CommandQueue>();
    CommandPtr pr=std::make_shared<Command>( exp);
    commands_to_execute->push_back(pr);  
}

I hope someone could help me, because It's very weird for me.

Thank you!!

有帮助吗?

解决方案

Your forgot to include the string header:

#include <string>

in Command.hh.


On a related note, maybe it's a good idea to make the constructor accept an std::string:

Command(const std::string& exp) {

instead of a const char*.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top