0

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!!

1 Answer 1

1

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*.

Sign up to request clarification or add additional context in comments.

1 Comment

Awww!!! As I said to "juanchoPanza", I didn't see why!! I was looking for the error a lot of time!! And thank you for your idea ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.