我在课程中定义了typedef std::vector<ColorInfo*> ColorInfoVector;
struct ColorInfo
{
ColorInfo() : m_displayVector() {}
// data members
DisplayAttrVector m_displayVector;
};
我在方法中获得输入
void Display (ColorInfoVector *colorInfoVector)
在我尝试访问成员变量时的方法,如下面的结构
DisplayAttrVector dispAttrs = (*(colorInfoVector[i]))->m_displayVector;
得到错误
error C2100: illegal indirection
error C2039: 'm_displayVector': is not a member of 'std::vector<ColorInfo *>'
答案 0 :(得分:1)
应该像这样工作:
// Gets your config section. It won't parse the xml to a
// key/value structure, but does provide the raw xml
var b = config.GetSection("AutoUpdate/Settings");
var rawXml = b.SectionInformation.GetRawXml();
// Get the raw xml value and load it to a queryable XDocument object
var doc = XDocument.Parse(rawXml);
doc.Descendants("add")
.Single(x => x.Attribute("key").Value == "ServerUrl")
.SetAttributeValue("value", "http://newthing.xml");
// Set the new xml back to the configuration object and persist the changes
b.SectionInformation.SetRawXml(doc.ToString());
config.Save(ConfigurationSaveMode.Modified, true);
答案 1 :(得分:1)
排队
DisplayAttrVector dispAttrs = (*((*colorInfoVector)[i]))->m_displayVector;
(*colorInfoVector)[i]
给你一个指针。要使用指针访问结构的成员,您需要编写
((*colorInfoVector)[i])->m_displayVector
或
(*((*colorInfoVector)[i]))).m_displayVector
两者都做同样的事情。