On 2005-02-05 22:59:08 -0500, "Slugger819" <abe819@gmail.com> said:
[color=blue]
> I'm creating a class SString , it should be just string
> here what I have for the private data member[/color]
Assuming that you're doing this as a learning experience (otherwise,
just use std::string)
[color=blue]
>
> int count_;
> int capacity_=0;
> char* str = new char[capacity_];[/color]
You cannot initialize members like this. Remember that the members
don't actually exist outside of instances of your class.
[color=blue]
>
> and here is my constructor :
>
> SString::SString (int capacity=50):capacity_()
>
> {
> capacity_=capacity;
> }[/color]
Try this:
SString::SString(int capacity=50)
: count_(0), capacity_(capacity), str(new char[capacity_])
{
}
[color=blue]
>
> but for some reason I'm getting a lots of errors I have all the
> #includes statements and all the ";" please help me and
> lemme know what I'm doing wrong[/color]
Even if you still don't want to use std::string, might I suggest using
std::vector<char> for your internal storage, instead of a raw character
array.
--
Clark S. Cox, III
clarkcox3@gmail.com