hello everone

i'm new to c++ language

Is This possible to make prg in cpp to overload () Opratore

if yes, then can u pls give any logical flow for develope the prg

i.e. which kind of opeartion can be performed through () opratore

thanx in advance

Recommended Answers

All 5 Replies

Are you thinking about using the () as the conversion operator or talking about overloading the () operator to do something like addition or concatenation or some other theoretical possibility?

hi......

i have some idea that in overloading of + operatore we can

perform summation or can concate to string

so whould u pls tell me which kind of

operation should i perform for overload the

() as operatore

When you overload the () operator, it's used as if it were a function call operator and nothing more:

#include <iostream>

struct foo {
    void operator()()
    {
        std::cout<<"FOO!\n";
    }
};

int main()
{
    foo bar;

    bar();
}

If that's not what you want, you're SOL.

yes i aggre whith u but

whould u pls suggest me which kind of operation

is suitable for overloading () as operatore

It sounds disturbingly like you're looking for a problem to fit the solution you recently learned. That's silly.

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.