Click to See Complete Forum and Search --> : C++ help


honz
04-02-2002, 11:59 PM
hey all. im tryin to get into C++, as i wanna try out linux, and have been told u need to have a good background in C++ to successfully do that. im stuck on the classes thing. i have experience in Visual Basic, but it to my knowledge is nothing like this. or mebbe im jus totally overlooking this. ne wayz, is there a simple way to explain this? or mebbe a tutorial that would help? TIA

mefisto3
04-03-2002, 12:15 AM
i am sure there are lots of tutorials and explanations out there. just look up object oriented programming.

in oo programming everything is done on objects and basically classes are used to encapsulate objects. there is a lot more to it of course. there are loads of books that cover this subject. can't remember any titles of the top of my head but i'm sure someone else can give u few titles.

dighn
04-03-2002, 05:35 AM
the choices in that poll are rather extreme but anyway you don't need to know c++ to use linux effectively ;)

there are tons of books on c++, most of them are good for beginniners

biosx
04-03-2002, 10:41 AM
Your poll is quite extreme to say the least.

You don't need to know C++ to learn/use Linux. It is mostly coded in C anyway (not C++). If you are solid with C, you can use the tcsh (the c shell), and be on your way to easy shell programming.

Classes aren't as hard as you think. You know what a structure (struct) is? Well if you do, just think of a class as a structure that can hide data within itself and have functions embedded inside it (called methods or member functions) that can act on the data the structure/class contains.


struct Rectangle
{
int pt1; // Upper left hand point
int pt2; // Lower right hand point
double area; // Area of rect (must be computed outside struct)
};


and with a class, you can do:

class Rectangle
{
public:
int getPtOne(); // Access function for pt1
int getPtTwo(); // Access function for pt2
double getArea(); // Access function for area
void computeArea(); // Will compute area with pt1 & pt2 and store in area

protected:
int pt1; // Upper left hand point
int pt2; // Lower right hand point
double area; // Area of rectangle (can now be computed inside class)
};


With the class, you can take all the actions that can or will be performed on it's data and put it inside the class. Also, you can hide the data within the class so only the functions that should have access to them do.

I hope this example helps a little bit.

And for the poll: I think you need to learn a little bit of Win32 programming to realize how nice Windows is. I enjoy UNIX programming, though, much more due to the fact that the API is nothing but a bunch of library functions ;)

gryps
04-03-2002, 12:03 PM
Choices are a bit extreme in your poll so i didn't vote.

C++ is not that hard for a newbie i would recomend
"C++ the complete language" it is published by wrox, i forget the author. Its probably the best c++ book i ever read.

honz
04-03-2002, 12:27 PM
okok so mebbe the choices are a bit extreme... =D ne wayz, i guess i didn't explain myself well. i kinda understand the basics of classes, i jus have trouble with the code. thx fer the start biosx. that was kinda wat i was lookin for. also, i'll look for that book, thx all

clickx17
04-03-2002, 07:28 PM
Umm Windows doesn't suck that much, but to use linux you don't need a great background in C++ infact C++ is a hard language to learn, I am almost fluent in it.