consolidate all repos to one for archive
This commit is contained in:
45
semester_2/programiranje_2/primeri/Example31/main.cpp
Normal file
45
semester_2/programiranje_2/primeri/Example31/main.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#include <iostream>
|
||||
|
||||
void f(int) {
|
||||
std::cout << "Calling function f(int)" << std::endl;
|
||||
}
|
||||
|
||||
void f(double) {
|
||||
std::cout << "Calling function f(double)" << std::endl;
|
||||
}
|
||||
|
||||
void f(char*) {
|
||||
std::cout << "Calling function f(char*)" << std::endl;
|
||||
}
|
||||
/*
|
||||
template <typename T>
|
||||
void f(T) {
|
||||
std::cout << "Calling function that is instantiated from template" << std::endl;
|
||||
}
|
||||
*/
|
||||
|
||||
void f(int, double) {
|
||||
std::cout << "Calling function f(int, double)" << std::endl;
|
||||
}
|
||||
|
||||
void f(double, double) {
|
||||
std::cout << "Calling function f(double, double)" << std::endl;
|
||||
}
|
||||
/*
|
||||
void f(double, int) {
|
||||
std::cout << "Calling function f(double, int)" << std::endl;
|
||||
}
|
||||
*/
|
||||
|
||||
int main() {
|
||||
f('a'); // f(int) – numeric promotion
|
||||
f(0); // f(int) – exact match
|
||||
//long a=5L;
|
||||
//f(a); //ambiguous, long to int, and long to double are standard conversions
|
||||
//f(double(a)); // ambiguity is resolved by explicit conversion
|
||||
|
||||
// 1. parameter {f1} 2.parameter {f1, f2}: {f1} intersection {f1, f2} = {f1}
|
||||
f('a', 1); // f(int, double)
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user