Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

My Anus

Name: Anonymous 2008-09-26 8:56

1. Time complexity of string::size()? Can't find it anywhere. I'm trying to decide if

int size = string.size()
for(int i(0); i < size; i++)
  dostuff();

is less complex than

for(int i(0); i < string.size(); i++)
  dostuff();

If it's anything other than constant (ie. a lookup), then doing the latter is really, really bad practise.

2. Is:

this->memberFunction();

an appropriate call for an instance of a self-member in a member def? ie.

int cat::number(int a)
{
  if(a < 10)
  {
    cout << a << endl;
    this->number(a++);
  }
}

3. hax my anus

Name: HMA 2008-09-26 9:13

1. A string is essentially an array of characters. Think about it. Also, premature optimization for anything but terribly long strings that you won't be using.
2. Yes, and you could even access attributes via this->attr = 1234. Try to name your methods with verbs, btw, cat::number sounds a lot more like an ID variable or something.
3. Done.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List