Hey Albinopapa

The Partridge Family were neither partridges nor a family. Discuss.
albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Hey Albinopapa

Post by albinopapa » June 4th, 2015, 6:12 pm

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.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Hey Albinopapa

Post by albinopapa » June 6th, 2015, 7:24 am

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.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
LuisR14
Posts: 1248
Joined: May 23rd, 2013, 3:52 pm
Location: USA
Contact:

Re: Hey Albinopapa

Post by LuisR14 » June 7th, 2015, 2:58 am

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
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat :mrgreen: --

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Hey Albinopapa

Post by albinopapa » June 7th, 2015, 4:10 pm

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.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
LuisR14
Posts: 1248
Joined: May 23rd, 2013, 3:52 pm
Location: USA
Contact:

Re: Hey Albinopapa

Post by LuisR14 » June 7th, 2015, 10:16 pm

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)
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat :mrgreen: --

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Hey Albinopapa

Post by chili » June 8th, 2015, 1:08 am

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.
Chili

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Hey Albinopapa

Post by albinopapa » June 8th, 2015, 6:17 am

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.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Hey Albinopapa

Post by albinopapa » October 7th, 2017, 11:48 pm

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.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Hey Albinopapa

Post by Yumtard » October 8th, 2017, 12:00 am

Is Chili now fully over texas holdem? Because that makes 1.5 of us

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Hey Albinopapa

Post by albinopapa » October 8th, 2017, 4:50 am

Well, this was two years ago, so maybe.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Post Reply