为什么会报错呢?
#include <list>
#include
namespace Component_WCH
{
char Button[] = "Button";
class Component
{
private:
std::list<char[]>Component_attribute;
public:
void initVariable()
{
Component_attribute.push_back("Button");//type
Component_attribute.push_back("0");//X
Component_attribute.push_back("0");//Y
Component_attribute.push_back("80");//Width
Component_attribute.push_back("35");//Height
Component_attribute.push_back("button");//Text
}
std::list<char[]> getComponent()
{
return Component_attribute;
}
};
}
D:\development\C++ development\library\window_WCH\Component.h:15:55: error: no matching function for call to 'std::__cxx11::list::push_back(const char [7])'
15 | Component_attribute.push_back("Button");//type
| ^
In file included from d:\c\lib\gcc\mingw32\9.2.0\include\c++\list:63,
from D:\development\C++ development\library\window_WCH\Component.h:1,
from D:\development\C++ development\library\window_WCH\window.h:4,
from View++/main.cpp:2:
为什么呢?
std::list<char[]>改为std::list<const char*> ,char[]数组大小不明确。