我不明白为什么视图给我一个非静态成员引用必须相对于特定对象的错误。
CDrawView::Shape是我在我的上声明的一个枚举CDrawView
enum shape{line, rect, elli};
shape current_shape;
Run Code Online (Sandbox Code Playgroud)
这是我的另一堂课
class Shapemaker
{
public:
CDrawView view;
static void Create(CDrawView::shape )
{
if(view.current_shape == view.line)
{
view.m_shape.reset(new Line());
}
else if(view.current_shape == view.rect)
{
view.m_shape.reset(new Rect());
}
}
}
Run Code Online (Sandbox Code Playgroud)
避免此错误的最佳做法是什么
我有一个linked_list,目前我的析构函数不能正常工作.不完全确定原因.有人可以解释一下如何解决这个问题吗?
class linked_list {
private:
struct node
{
// String in this node
std::string data;
// Pointer to next node
struct node *next;
};
//First item in the list
struct node *first;
Run Code Online (Sandbox Code Playgroud)
这是我的析构函数
linked_list::~linked_list(void)
{
while (first)
{
delete first;
first = first->next;
}
}
Run Code Online (Sandbox Code Playgroud)