Question
Accessing a protected member in derived class
I have a circle of varying width. I created a subclass that was inherited by Screen1ViewBase class. I want to access protected members of ScreenViewBase.
Screen1ViewBase;
#ifndef SCREEN1VIEWBASE_HPP
#define SCREEN1VIEWBASE_HPP
#include <gui/common/FrontendApplication.hpp>
#include <mvp/View.hpp>
#include <gui/screen1_screen/Screen1Presenter.hpp>
#include <touchgfx/widgets/Box.hpp>
#include <touchgfx/widgets/canvas/Circle.hpp>
#include <touchgfx/widgets/canvas/PainterRGB565.hpp>
class Screen1ViewBase : public touchgfx::View<Screen1Presenter>
{
public:
Screen1ViewBase();
virtual ~Screen1ViewBase() {}
virtual void setupScreen();
protected:
FrontendApplication& application() {
return *static_cast<FrontendApplication*>(touchgfx::Application::getInstance());
}
/*
* Member Declarations
*/
touchgfx::Box __background;
touchgfx::Box box1;
touchgfx::Circle circlewidth;
touchgfx::PainterRGB565 circlewidthPainter;
private:
/*
* Canvas Buffer Size
*/
static const uint16_t CANVAS_BUFFER_SIZE = 7200;
uint8_t canvasBuffer[CANVAS_BUFFER_SIZE];
};
#endif // SCREEN1VIEWBASE_HPPScreen1View.cpp;
#include <gui/screen1_screen/Screen1View.hpp>
#include<gui/WidthChange.hpp>
Screen1View::Screen1View()
{
}
void Screen1View::setupScreen()
{
Screen1ViewBase::setupScreen();
}
void Screen1View::tearDownScreen()
{
Screen1ViewBase::tearDownScreen();
}
void Screen1View::handleTickEvent()
{
WidthChange::Change();
}This is the header of my class;
#ifndef WIDTHCHANGE_HPP
#define WIDTHCHANGE_HPP
#include <gui/screen1_screen/Screen1View.hpp>
#include <gui_generated/screen1_screen/Screen1ViewBase.hpp>
class WidthChange : public Screen1ViewBase
{
public:
static void Change();
};
#endifand cpp;
#include <gui/WidthChange.hpp>
#include <gui_generated/screen1_screen/Screen1ViewBase.hpp>
#include <gui/screen1_screen/Screen1View.hpp>
#include <gui/screen1_screen/Screen1Presenter.hpp>
void WidthChange::Change()
{
float currentRad;
float lineWidth;
circlewidth.invalidate();
circlewidth.getRadius(currentRad);
if (currentRad >= lineWidthLimit)
{
circleWidthChangeFactor = -0.25;
}
else if (currentRad<= 15)
{
circleWidthChangeFactor = 0.25;
}
currentRad = currentRad + circleWidthChangeFactor;
circlewidth.setRadius(currentRad);
circlewidth.getLineWidth(lineWidth);
circlewidth.setLineWidth(lineWidth + 2 * (circleWidthChangeFactor * (-1)));
circlewidth.invalidate();
}Screen1View can access the protected members of Screen1ViewBase. Why can't I access them?