Basically, I have two classes declared in a header file:
class Version
{
...
};
class BasicRegex
{
...
std::vector<std::string> split(std::string parseString);
...
};
Then, in the implementation file, I want to use an instance of the
BasicRegex class in the implementation of a member function of Version. It
seems to compile fine when I declare a local object of type BasicRegex in
the Version member function, but then when I try to call the member function
split(), VS.NET compiler gives the following error:
error C2228: left of '.split' must have class/struct/union type
void Version::setVersion(std::string parseString)
{
if(parseString == "") return;
BasicRegex regex(std::string(separator_)); // separator_ is private
member data in Version, just a char
std::vector<std::string> nums;
nums = regex.split(parseString); // here's the problematic line
nums_.resize(nums.size()); // nums_ is also local data for
Version
for(int i = 0; i < nums.size(); i++)
{
nums_[i] = std::atoi(nums[i].c_str());
}
}
I can use the BasicRegex object outside of the implementation file (and the
split member function works fine, so it has something to do with scope here
I think).
What can I do to fix this?
Thank you,
Kevin Grigorenko