473,394 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Implementation problem

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
Jul 19 '05 #1
2 2103
Kevin Grigorenko wrote in news:bp***********@f04n12.cac.psu.edu:
BasicRegex regex(std::string(separator_)); // separator_ is
private


The above declares a function:

BasicRegex regex( std::string seperator );

Parenthesis are allowed to surround the identifier part of a declaration
to allow stuff like:

int (*pointer_to_array)[3];

Solution 1:

BasicRegex regex( (std::string( seperator ) ) );

Solution 2 (needs an accesable copy-ctor, but shouldn't call it):

BasicRegex regex = BasicRegex( std::string( seperator ) );

HTH.

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 19 '05 #2
"Rob Williscroft" <rt*@freenet.REMOVE.co.uk> wrote in message
news:Xn**********************************@195.129. 110.205...
Kevin Grigorenko wrote in news:bp***********@f04n12.cac.psu.edu:
BasicRegex regex(std::string(separator_)); // separator_ is
private

The above declares a function:

BasicRegex regex( std::string seperator );

Parenthesis are allowed to surround the identifier part of a declaration
to allow stuff like:

int (*pointer_to_array)[3];

Solution 1:

BasicRegex regex( (std::string( seperator ) ) );


Wow, that was simple, Thank you!

Solution 2 (needs an accesable copy-ctor, but shouldn't call it):

BasicRegex regex = BasicRegex( std::string( seperator ) );

HTH.

Rob.
--
http://www.victim-prime.dsl.pipex.com/

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: IK | last post by:
Hello All, Please excuse me for posting this here, but I don't find any other group where I will get a proper answer. This is about clarifying the C++ part of COM. I understand that COM is a...
5
by: Keith Patrick | last post by:
Could someone tell me if it's possible (and if so, how) to call an explicitly-implemented interface method from a subclass? I have a class in which I have to explicity implement some methods, but...
4
by: Rubbrecht Philippe | last post by:
Hi there, I would like to develop an interface that when implemented in a class requires a number of shared properties or methods to be available. It seems a Shared Member can not be used as...
16
by: Jordan Abel | last post by:
I have written this function and was wondering if anyone else could point out if there's anything wrong with it. The purpose is to substitute for printf when in a situation where low-level I/O has...
8
by: Jef Driesen | last post by:
I'm working on an image segmentation algorithm. An essential part of the algorithm is a graph to keep track of the connectivity between regions. At the moment I have a working implementation, but...
18
by: bsruth | last post by:
I tried for an hour to find some reference to concrete information on why this particular inheritance implementation is a bad idea, but couldn't. So I'm sorry if this has been answered before....
20
by: Luc Kumps | last post by:
(Sorry about the previous post, it got transmitted before it was complete) We try to separate implementation and interface defintions, but we run into a problem. I hope the guru's can solve this,...
14
by: embeddedc | last post by:
Hi, Referring to C90, is there somewhere published a list of all parts of the standard where the behavior is not specified or implementation dependent? If not and I want to find all such...
1
by: Fredo | last post by:
I'm getting the following error when I'm running my application (application name changed for the example): Unhandled Exception: System.TypeLoadException: Method get_ImageFile in type...
3
by: C++Liliput | last post by:
Hi, I was looking at the implementation of operator new and operator new in gcc source code and found that the implementation is exactly the same. The only difference is that the size_t argument...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.