Regards

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
zodiac976
Chaos Rift Regular
Chaos Rift Regular
Posts: 156
Joined: Thu Jun 18, 2009 10:03 am
Current Project: Booklet & Text RPG
Favorite Gaming Platforms: PC, PS3, PSP
Programming Language of Choice: C++
Location: AL
Contact:

Regards

Post by zodiac976 »

I would like to thank everyone for helping me understand
scopes of classes, pointers and dynamic objects. I am
actually using pointers now in my code :mrgreen: and
this:

Example: Character * ptrChar = new Character(); //parameters if I need them

Really comes in handy and also "this pointer" to 8-).
User avatar
davidthefat
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 529
Joined: Mon Nov 10, 2008 3:51 pm
Current Project: Fully Autonomous Robot
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: California
Contact:

Re: Regards

Post by davidthefat »

zodiac976 wrote:I would like to thank everyone for helping me understand
scopes of classes, pointers and dynamic objects. I am
actually using pointers now in my code :mrgreen: and
this:

Example: Character * ptrChar = new Character(); //parameters if I need them

Really comes in handy and also "this pointer" to 8-).
I really need to get onto pointers, I kinda get it but not really... Its like you did Algebra, now go onto Algebra 2
User avatar
zodiac976
Chaos Rift Regular
Chaos Rift Regular
Posts: 156
Joined: Thu Jun 18, 2009 10:03 am
Current Project: Booklet & Text RPG
Favorite Gaming Platforms: PC, PS3, PSP
Programming Language of Choice: C++
Location: AL
Contact:

Re: Regards

Post by zodiac976 »

I got a little worried about not using pointers in my new project
but I went back today and plugged in pointers where they are
needed and not only does the program run good it looks great
and is more toward OOP :mrgreen:.

I could go on with a huge list of what I learned so far but I can
say I learned a lot more here than I did in college classes.

I can't wait to finish my text-based RPG and show it off ;).
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: Regards

Post by Ginto8 »

Character*? I'm hoping you don't mean a substitution for char, because dynamic arrays of chars are about the most useful things in C++. example of a possible use for them (a static array would probably be more appropriate for certain parts):

Code: Select all

char* myCStyleStr = calloc((strlen("Hello World!") + 1) * sizeof(char));
strcpy(myCStyleStr, "Hello World!");
printf("%s\n", myCStyleStr);
myCStyleStr = realloc(myCStyleStr, strlen("Hello World! and Mars too!") + 1);
strcpy(myCStyleStr + strlen("Hello World!") + 1, " and Mars too!");
printf("%s\n", myCStyleStr);
free(myCStyleStr);
getchar();
stick that in main() and you'll get the output:

Code: Select all

Hello World!
Hello World! and Mars too!
so char arrays (especially dynamic) are extremely useful, and I'm hoping you didn't make a class to substitute them, because that's just clunky and wasteful :x .
</rant>
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
zodiac976
Chaos Rift Regular
Chaos Rift Regular
Posts: 156
Joined: Thu Jun 18, 2009 10:03 am
Current Project: Booklet & Text RPG
Favorite Gaming Platforms: PC, PS3, PSP
Programming Language of Choice: C++
Location: AL
Contact:

Re: Regards

Post by zodiac976 »

Ginto8 wrote:Character*? I'm hoping you don't mean a substitution for char, because dynamic arrays of chars are about the most useful things in C++. example of a possible use for them (a static array would probably be more appropriate for certain parts):

Code: Select all

char* myCStyleStr = calloc((strlen("Hello World!") + 1) * sizeof(char));
strcpy(myCStyleStr, "Hello World!");
printf("%s\n", myCStyleStr);
myCStyleStr = realloc(myCStyleStr, strlen("Hello World! and Mars too!") + 1);
strcpy(myCStyleStr + strlen("Hello World!") + 1, " and Mars too!");
printf("%s\n", myCStyleStr);
free(myCStyleStr);
getchar();
stick that in main() and you'll get the output:

Code: Select all

Hello World!
Hello World! and Mars too!
so char arrays (especially dynamic) are extremely useful, and I'm hoping you didn't make a class to substitute them, because that's just clunky and wasteful :x .
</rant>
no Character is an object of a class not the data type char.
I hardly use c-strings as I always fall back on the string
object.
Post Reply