Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

HOTSHOT

Newbie C++! Please Help!

This topic is 5835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hiya all I have been programming Pascal and C before but not c++! I do know how function work. But I dont know how class, private or public work....can anyone help me out please? Cheer all HOTSHOT P.S. it would be nice if someone teach me from Pascal to c++ cos I will be able to understand as I''m master of Pascal but not c++....I hope u understand what I''m saying!

Share this post


Link to post
Share on other sites
Advertisement
The following link is to a free C++ book that''ll teach you about C++ programming, and of course OOP.

http://www.xtremejava.com/books/index.html

Else, get C++ Primer by Lipmann from Amazon or another book-pusher.

ENJOY

**************************
A year spent in artificial intelligence is enough to make one believe in God.

Share this post


Link to post
Share on other sites
To get the basics down you could start here, which is a list of beginner tutorials and free online books for C++ programming (the links at the top will take you to more advanced concepts). If you're willing to spend some money you can buy C++ For Pascal Programmers. Finally if you don't have a c++ compiler I would suggest trying Bloodshed, which is a free C++ compiler for windows.

These resources should get you started in C++ programming, when you get stuck on something or find a tutorial doesn't explain a particular concept very well drop in and post a message. There are lots of people on this site willing to help out, I'm here most of the day (Eastern Time, US & Canada) either answering questions or engaging in conversations in the lounge, and other members like Saberman seem to spend most of their Gamedev time helping people in this forum and others.


[edited by - Michalson on June 25, 2002 5:14:11 PM]

Share this post


Link to post
Share on other sites
It seems like you have the same knowledge as I had for a short time ago. I was programming C for some time but did actually never learn anything advanced, I did almost loose all my motivation (I couldnt get anything working; how depresing!), until I bougth the book "teach yourself C++ in 21 days". As I read did I find out that I knew less than what the book teached the first five days! I'm about finishing the second week now and is beginning to read "windows gameprogramming for dummis" (contents directX and Windows-programming) parallelly (I didnt spell that right huh? ), something I never thought I was able to do! Try theese (or some other) books, succes is the only thing that keeps us motivated!
__________________________________
Just forget about it! I won't write any kind of a profile signature!

[edited by - the Chef on June 25, 2002 5:51:58 PM]

Share this post


Link to post
Share on other sites
Hiya all,

Thank to all for helping me. Hey Michalson, which bloodshed...should I download?

This is my first program!

// Age program
# include
# include
# include
//my first c++

Class Person
{
Private
int age;
Public
void setage();
void showage();
}

void person :: setage();
{
int n;

puts("your age");
scanf("%d%c",&n)
age=n;
}

void person :: showage();
{

printf("Person is "%d"\n,age)

}

Main
{

clrscr();

Person pete
pete.setage();
pete.showage();
getchar();
}

I think I have done well on my first program but I''m fast learner...as I''m deaf person myself...and what do u think of above code then?

This program above I using is boardland 1.0( I dont think I have spell it right)

Can anyone explain what class is as I like to know them more...

Thank for reading this

HOTSHOT

Share this post


Link to post
Share on other sites
You''re deaf? Cool, I''m deaf also! Nice knowing that I''m not the only deaf person in GD.net

Okay, classes (or structs, they''re both the same, except classes automatically have all of its members private, struct, public, unless you declare otherwise using private: and public are a group of members (variables, functions, etc) that is contained in one data. This is very handy for making games because you can declare a CPlayer with health, inventory, etc... Private members cannot be accessed outside the class, you have to access them via functions that is public.

______________________________________________
You know your game is in trouble when your AI says, in a calm, soothing voice, "I''m afraid I can''t let you do that, Dave"

Share this post


Link to post
Share on other sites
I''m not an expert on class, but classes define objects. For example, you can have a class Car, and in Car, you would have methods for everything a car can do (start, move, crash, etc...) Realistically, I find myself using classes less for "tangible" things such as cars, and more for somewhat abstract things such as interfaces and sprites. But anyway, the beauty of using classes is that they are easy to maintain (at least in theory; some people might argue this, but I find them to be invaluable, myself) and are easily reusable as well. This isn''t so much an issue for games usually, but its a nice feature to have, in any case.

Share this post


Link to post
Share on other sites
A class is C++'s (and also Java's) mechanism for implementing the object oriented concept of encapsulation.

Ok, let's try that again in English.

Basically, classes let you define a type of object and all the operations and actions that are valid for that kind of object. Peon's car example is a good one. If you've ever used structs in C, classes are a very similar concept, except they can also contain functions (or more properly, methods) as well as data.

Classes also allow you to control who can access what. This is done with the keywords public, protected and private. Things declared in a public block can be accessed by anyone. Protected members of a class can only be accessed by that class and any class that's derived from that class. Private members can only be accessed by that class.

quote:
Original post by Peon
This isn't so much an issue for games usually, but its a nice feature to have, in any case.


I have to disagree with you here a little. The reusablility and maintainablity of classes are extrememly important in software as compilcated as games. The more help we can get, the better.

/*=========================================*/
/* Chem0sh */
/* Lead Software Engineer & Tech Support */
/* http://www.eFaces.biz */
/*=========================================*/

[edited by - Chem0sh on June 25, 2002 11:54:28 PM]

Share this post


Link to post
Share on other sites
Chem0sh: Perhaps I''m thinking on too small a scale in that case; I don''t have ANY experience working on large projects. I meant it in that unlike programs like Windows, once a game is written, its not AS likely that the code will need to be reused. Some of it might be, if it''s effective, but I don''t think (keep in mind I''m just speculating here ) that the majority of code is reused in say, a sequel.

Share this post


Link to post
Share on other sites
As far as game specific code is concerned, you're probably right, Peon. Where reusability really comes in is with the engine (think Quake 2/3, Lithtech, etc). Writing an engine is a long, hard process (actually, I'm just now working on the one in ToTWGPG myself, but I've seen the full Quake 2 source). You want to squeeze as much use out of an engine as possible. Of course, by the time one would start working on the sequel, you'd probably want to have a new engine too. Anything you don't have to rewrite saves you time.

/*=========================================*/
/* Chem0sh */
/* Lead Software Engineer & Tech Support */
/* http://www.eFaces.biz */
/*=========================================*/

[edited by - Chem0sh on June 26, 2002 6:11:15 AM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!