/* Simple class template having simple function template */ #include "iostream" using namespace std; template <class T> class Person{ T age; public: void getData(T a){ age = a; } T showData(); }; template <class T> T Person<T> :: showData(){ return age; } int main(){ Person <int> ob; ob.getData(32); cout<<"\nage: "<<ob.showData()<<endl; return 0; } /* OUTPUT [pavan@Pavan ClassTemp]$ g++ ClassTemp3.cpp [pavan@Pavan ClassTemp]$ ./a.out age: 32 [pavan@Pavan ClassTemp] */
The Tech Zone is built to promote open source technologies. Hadoop, Linux Administration, Cloud, Java Technologies, Operating Systems, Advanced Computer Programming, etc are the key areas of focus. Computer and IT engineering students can find important study material on this portal.
Thursday, 21 September 2017
Simple class template having simple function template in C++
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment