Respected Sir,
         I am not understanding classes so i want to learn what classes are and in what kind of problems we can use it.And Can u plz tell me in detail with examples that how can we use classes in getting inputs from authenticated users and storing data to file?

Hello Irshad, thank you for the question.

The reason for classes is so we can group together data that describes a particular object, as well as an interface to the data. Here is a basic example of a class.

class Car

int GetMPH() { return mph; }
void SetMPH(int m) { mph = m; }

int GetWheels() { return numWheels; }
void SetWheels(int w) { numWheels = w; }  

int mph;
int numWheels;

We can use the class Car to organize a set of data that could describe a car. You can use classes to retrieve and store data in methods if you wanted. Maybe the car class could have a method on called WriteToFile(), and LoadFromFile() that could manage the file IO aspect of the class data. This is pretty long discussion to get into, so I would highly suggest reading some in a good C++ reference book, which will go into far more detail than I am capable of.

I hope this information was helpful.

- Eddie


All Answers

Answers by Expert:

Ask Experts




I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by ExpertRating.com. I also know a good deal about graphics via OpenGL, and GUIs.


I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2016 About.com. All rights reserved.