different types without template

Hi, I am wondering how can I make something like this:
1
2
3
4
5
6
7
8
9
int check()
{
do something...........
}

double check()
{
do something..........
}


My teacher says that I cannot use template in the assignment.

So how can I do it?
You can overload functions, the compiler uses the number and type of the arguments and whether the function is const (for class functions) to determine which version of the function to execute.

Does this help?
so what you mean is I can do this?

1
2
3
4
5
6
7
8
9
int dothis(int temp)
{

}

double dothis(double temp)
{

}


and depends what type put for temp, it will get in that function?
yes.

Also:

1
2
3
4
double dothis(double temp1, double temp2){}
double dothis(double temp1, int temp2){}
double dothis(double temp1, char temp2){}
double dothis(double temp1, double temp2, double temp3){}


As I said, along as the number & type of the arguments produces a unique combination.

Overloading applies to constructors, destructors, and operators too.

Good Luck :+)
Just a note: overloading resolution will take into account only function arguments, not return value. That means you cannot do that:
1
2
double dothis(int x);
int    dothis(int x);
Topic archived. No new replies allowed.