Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

How do I get a value from a child class(Thats inside a class) in c++?

I couldn't out how to do this but I want to try and figure out how. I've been looking it up for 20 minutes without any results that help me out here.

CPP File

    void IDS::newId()
{
    // ID id;
}

IDS::~IDS()
{
    int x = 0;
    while (x < idList.size()) {
        idList.remove(x);
        x++;
    }
}

IDS::IDS()
{
    newestId = 1; 

}

IDS::ID::ID()
{
    // This Is where I need help

    int x = //  The newest id (Thats in parent class) - 1
}

IDS::ID::~ID()
{
    delete &id;
}

int IDS::ID::getId()
{
    return id;
}

Header

class IDS
{
public:
    int newId();
    ~IDS();
    IDS();
private:
    int newestId;
    class ID {
    public:
        ID();
        ~ID();
        int getId();
        int newestId;
    private:
        int id;
    };
public:
    std::list<int> idList;
};

Just so you know most things that are in comments are placeholders that I do not know how to do yet. You can tell me how to do those if you want :)

Comments