hi i was wondering how much i should use classes in C++.
Should i use it as much as possible?

>i was wondering how much i should use classes in C++.
As often as you need them, obviously. In my experience, this question is born of ignorance. You don't understand OOP and classes well enough to know when to use them, so you try to turn it into some kind of nonsensical numbers game. It's not that simple, unfortunately.

Just try to figure out the concepts behind a feature and eventually you'll learn when and where it's best used.

>Should i use it as much as possible?
:icon_rolleyes:

commented: Although someone harsh, I do agree! =) +4

>i am sorry
For what?

For what?

for misunderstanding the concepts of classes i thought that it was the core of an optimal program (like code at bottom of post) is it really only to reuse code?

class someClass
{
public:
    someClass();
    void someFunc();
    void someOtherFunc();
private:
    int someVariable;
    int someOtherVariable;
};

int main()
{
    someClass someObject;
    someObject.someFunc();
    someObject.someOtherFunc();
}

Classes can be used for many things...

The Programming perspective:

-Restricting access to encapsulated data/ standing in for the same type (Proxy)
-Abstractions for future data (Strategy, Bridge)
-Adding functionality to existing objects with the same interface (Decorator)
-Adapting an object to the interface of another (Adapter)
-Providing a commonality for iterating through a collection of objects (Iterator)
-Granting transparency between using one object, or many of the same type (Composite)
and so on in terms of patterns--


The Client/Programmer perspective:

-Easy to relate ideas into programmable objects.
-Easy (or easier) to identify problems in existing code when classes are used for job delegation.
the list goes on, but these are some advantages to name a select few #_#

>for misunderstanding the concepts of classes
That's hardly cause for an apology.

>is it really only to reuse code?
Classes are an organizational tool, nothing more. There are many, many ways you can use that tool to achieve many, many results, but at the core classes are just another way of structuring your code.

thank you everyone

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.