MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / derivedFun

Method derivedFun

Examples/Modules/Chapter 17/Ex17_06/Ex17_06.cpp:27–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25
26template <typename T>
27void Derived<T>::derivedFun()
28{
29 // These two lines should give compiler errors.
30 // Uncomment the using declarations in the Derived<> template
31 // to make them work. Alternative solutions are illustrated below.
32 baseFun();
33 std::cout << m_base_var << std::endl;
34
35 // Option 1: add this->
36 this->baseFun();
37 std::cout << this->m_base_var << std::endl;
38
39 // Option 2: add Base<T>::
40 Base<T>::baseFun();
41 std::cout << Base<T>::m_base_var << std::endl;
42}
43
44int main()
45{

Callers

nothing calls this directly

Calls 1

baseFunMethod · 0.45

Tested by

no test coverage detected