我完全是共享指针的新闻。我正在尝试通过做初始化一个
std::shared_ptr<Gdiplus::Pen> pen(new Gdiplus::Pen);
但它说它需要一个类型说明符......我也在尝试将此共享指针设置为常规指针。谁能解释我这是如何工作的。非常感激
#pragma once
class Shape
{
public:
Shape();
Gdiplus::Point start;
Gdiplus::Point end;
std::shared_ptr<Gdiplus::Pen> pen(new Gdiplus::Pen());
virtual LRESULT Draw(Gdiplus::Graphics * m_GraphicsImage) = 0;
void setPen(Gdiplus::Pen * pen2) {
pen.get() = pen2;
}
void setStart(int xPos, int yPos) {
start.X = xPos;
start.Y = yPos;
}
void setEnd(int xCor, int yCor) {
end.X = xCor;
end.Y = yCor;
}
};