Page 2 of 2

Re: Hey Albinopapa

Posted: June 4th, 2015, 6:12 pm
by albinopapa
chili wrote:It amuses me to act like a jackass while recording, and therefore that is how I will continue to roll. I will however try to avoid sounding like a Tourettes case off his meds (when possible).
This caught my attention while reading your planetchili.net blog intro...hilarious.

Any ideas about a Wiki? Is it still going to be a thing?

If traffic picks up around here again I'd like to make it a thing. Right now I don't think the community is quite active enough to sustain one, unfortunately.

Re: Hey Albinopapa

Posted: June 6th, 2015, 7:24 am
by albinopapa
Ok, I hate const, it's a pain in the ass. Say you have a const object and you want to use one of it's methods to access a members. Normally, you can do this, but if the object is a const reference of another object and you want to access a method of that const ref, you have to copy it into an object before you can.

Example:

Code: Select all

class Bounds
{
 public:
       // const int Left() doesn't work either
        int Left()
        {
                return left;
        }

private:
        int left;
};
class Object
{
public:
        const Bounds& GetBounds()  // can't const the function, because I'm calling a non const function
        {
                 bounds.Update(Position, size);
                 return bounds;
        }
};
There is a snippet of the classes I have. Now if I want to call Left() from outside the Object class, in the Game class for instance

Code: Select all

int left = obj.GetBounds().Left() 
it tells me that the "object has type qualifiers that are not compatible with the member function. I can't make the Bounds object const because the boundaries will change as the object moves. Even making the returned value of Left() const doesn't work.

Using const may make sense most of the time, but sometimes, it's just a pain in the ass to work with.

Re: Hey Albinopapa

Posted: June 7th, 2015, 2:58 am
by LuisR14
lol, the only way to fix would be to make the Left() function const, as in

Code: Select all

        int Left() const
        {
                return left;
        }
that's the point of the const keyword after the member function pretty much
const after member function declaration just means it won't change the const object's data

Re: Hey Albinopapa

Posted: June 7th, 2015, 4:10 pm
by albinopapa
Can't believe that f*ing worked. The function takes no params, so not sure why the function has to be const, should just be worried about the returned value. Anyway, thanks, completely forgot to even try it since it didn't make sense, since I wasn't passing anything in.

Re: Hey Albinopapa

Posted: June 7th, 2015, 10:16 pm
by LuisR14
heh yea, pretty much const before the function means return value is const, after the function (only for member functions) means object won't be modified, and you know what it means everywhere else lol
(thought you knew all this lol xD)

Re: Hey Albinopapa

Posted: June 8th, 2015, 1:08 am
by chili
albinopapa wrote:The function takes no params, so not sure why the function has to be const, should just be worried about the returned value.
The const at the end the method signature means that the method will not alter the state of the object it is called on. Therefore, for const objects, only methods marked with const (i.e. non-mutating methods) are accessible.

Re: Hey Albinopapa

Posted: June 8th, 2015, 6:17 am
by albinopapa
Was under the impression, const at the end just meant the function wouldn't change a member value or params being passed in. Thanks for the corrections. Now I'm just having some design issues hehe. Will work a little more and see if I can't straighten them out, if not, I'll be back with a project.

Re: Hey Albinopapa

Posted: October 7th, 2017, 11:48 pm
by albinopapa
Hmm, I've come quite far with understanding const and now I don't even think about not using it everywhere I can. I've become as obsessed with it as chili...well I don't get rock hard so maybe not.

Re: Hey Albinopapa

Posted: October 8th, 2017, 12:00 am
by Yumtard
Is Chili now fully over texas holdem? Because that makes 1.5 of us

Re: Hey Albinopapa

Posted: October 8th, 2017, 4:50 am
by albinopapa
Well, this was two years ago, so maybe.