im learning c++.(using Sams-teach yourself C++ in 10 mins(per chapter)) I have been doing well and everything seems to be coming to me pretty easy,plus I am familar with programming from many years ago. anyway, ive got methods down fine, but classes seem to ellude me a bit. My study book doesnt really give me good examples, can someone please give me a simple sample program using a class file with a main file (example), that might help kick it into better perspective. not sure why this part is giving me a hard time, I understand basically what its for, but just cant seem to get it figured out. hopefully someone else who had trouble with this part can show me what they figured out that put it into perspective.
Ok, a class can have variable and functions in them. At the end of the class you define what objects are in that class (you can actually do this in made too). So say you had a class called Rectangle. Well rectangles always have a length and a width. So those would be the variables in that class. then you could have functions for setting the length and width, and one for calculating area ex:
the rect after the } declares an object called rect with the class Rectangle. That means it has a length and width and can use those functions.
ex rect.length = 5 would set the length of rect to 5.
Not sure if that clears anything up. I had problems with classes myself. Heres a great tutorial on them too. I found its a lot better to read like 3+ tutorials on the same subject, cause you get different viewpoints and explanations and it just clicks faster.