Oop Presentation
Oop Presentation
Group Members:
Muhammad Tahir : university roll number 1301-241019
Why?:
Syntax:
Key concepts;
1-Template Instantiation:
2-Multiple Types:
3-Template Specialization:
template <>
const char* add(const char* a, const char* b) {
return strcat(a, b); // Custom behavior for strings
}
Common Pitfall:
Basic Syntax:
Advanced Features:
STL Example:
Core Idea:
Examples:
1-Mathematical Constants:
template <typename T>
constexpr T pi = T(3.141592653589793);
cout << pi<double>; // High precision
2-Type-Dependent Values:
Why Useful?:
What?:
Example:
Array<10> arr; // N = 10
Use Cases:
Template Metaprogramming:
Compile-Time Power:
struct Factorial {
};
template <>
};
Real-World Use:
Don’ts:
Debugging Tips:
Real-World Applications:
1-STL Containers: vector<T>, map<K,V>.
Key Takeaways:
Q&A :
"What happens if you try to
instantiate Stack<Employee> without defining operator>?"
THANK YOU