Hello everybody, I want to overload a function based on an array dimension or pointers.
Ex:

int calc(int a[]);
int calc(int a[][]);

or

int calc(int *a);
int calc(int **a);

*a should be &a but i dont know how to face a reference of a reference so i wrote * for better understading...

Recommended Answers

All 4 Replies

C doesn't support function overloading, but because an added dimension or level of indirection constitutes a different type, you can do what you want in C++ (more or less).

Thank you for reading my thread.
How would you suggest to do this in cpp? Some example would be welcome.

>How would you suggest to do this in cpp?
I normally suggest that one learns how to do trivial things by reading a book. But if you must ask a question, I'd suggest posting in the C++ forum where someone qualified to help you with C++ can do so.

>Some example would be welcome.
Your pointer example is correct. The array example would be correct if you included the required size for the second dimension.

Sorry for bothering you and thank you!

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.