Class Limits

J

junkmonkey

Hey everyone. This is much more of a general question than a
code-specific one. For class, I need to write a text-based adventure
game. I know that I will be using classes to implement different
aspects of the game (player, rooms, traps, etc.) and was wondering what
are the limitations on classes. As of now, I know they basically
define a user-defined type, and have elements of that type. These
members can also be used in class specific functions called methods. I
guess what I'm getting at is how do I know what to make a class, and
what to make a simple variable. Secondly, how do I use pointers to
navigate from room to room?
Sorry about the broadness of this question, but I've been perusing
my notes and my understanding of classes is within my grasp, but
something fundamental is ultimately missing. Thanks again!

~junk
 
M

mlimber

junkmonkey said:
Hey everyone. This is much more of a general question than a
code-specific one. For class, I need to write a text-based adventure
game. I know that I will be using classes to implement different
aspects of the game (player, rooms, traps, etc.) and was wondering what
are the limitations on classes. As of now, I know they basically
define a user-defined type, and have elements of that type.

I'm not sure what "have elements of that type" means. Classes can have
members of any type.
These
members can also be used in class specific functions called methods. I
guess what I'm getting at is how do I know what to make a class, and
what to make a simple variable.

Generally speaking, classes are intended to encapsulate data behind an
interface so that the programmer can concentrate on behavior rather
than implementation details. (Then again, there are also policy classes
and other classes that don't fit this definition.) See these FAQs:

http://www.parashift.com/c++-faq-lite/classes-and-objects.html
Secondly, how do I use pointers to
navigate from room to room?

This question is unanswerable without more details since it depends
what your pointers point to.
Sorry about the broadness of this question, but I've been perusing
my notes and my understanding of classes is within my grasp, but
something fundamental is ultimately missing. Thanks again!

Do you have a good book such as _Accelerated C++_ by Koenig and Moo?

Cheers! --M
 
V

Victor Bazarov

mlimber said:
[..] Classes can have
members of any type.

<nitpick>
Classes cannot have elements of their own types, or any incomplete
types for that matter.
</nitpick>

V
 
N

Neil Cerutti

Hey everyone. This is much more of a general question than a
code-specific one. For class, I need to write a text-based
adventure game.

Unless you must use C++ as a condition of your project, I recommend
considering a couple of the domain-specific programming languages for
writing text-based adventure games, specifically, TADS and Inform. You
wouldn't have the fun/pain of developing your own world model or
natural-language parser, but you'd increase the robustness,
portability and development speed of your game considerably.
Sorry about the broadness of this question, but I've been perusing
my notes and my understanding of classes is within my grasp, but
something fundamental is ultimately missing. Thanks again!

Head on over to rec.arts.int-fiction for help. Most text adventures
are written in domain-specific languages nowadays, but there are a few
mavericks around, and lots of experienced "interactive fiction"
developers for you to learn from.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top