Announcements | Last Post | |
---|---|---|
SoC Curricula | 09/30/2017 01:08PM | |
Demarcation or scoping of examinations and assessment | 02/13/2017 07:59AM | |
School of Computing Short Learning Programmes | 11/24/2014 08:37AM | |
Unisa contact information | 07/28/2011 01:28PM |
Linker Errors March 16, 2009 07:18PM |
Registered: 15 years ago Posts: 14 Rating: 0 |
Re: Linker Errors March 17, 2009 08:11AM |
Registered: 18 years ago Posts: 560 Rating: 2 |
Re: Linker Errors March 17, 2009 08:48AM |
Registered: 15 years ago Posts: 14 Rating: 0 |
Re: Linker Errors March 17, 2009 08:57AM |
Registered: 18 years ago Posts: 560 Rating: 2 |
Re: Linker Errors March 17, 2009 09:39AM |
Registered: 16 years ago Posts: 2,075 Rating: 0 |
Re: Linker Errors March 17, 2009 09:45AM |
Registered: 18 years ago Posts: 560 Rating: 2 |
Re: Linker Errors March 21, 2009 02:53PM |
Registered: 18 years ago Posts: 1,424 Rating: 0 |
Re: Linker Errors March 21, 2009 03:22PM |
Registered: 18 years ago Posts: 1,424 Rating: 0 |
Language: C++template <typename Type> class MyClass { friend std::ostream& operator<< <Type>(std::ostream &sout, const linkedListType<Type> &list); public: /* omitted code */ }; template <typename Type> std::ostream& operator<< <Type>(std::ostream &sout, const linkedListType<Type> &list){ /* omitted code */ return sout; }
Re: Linker Errors March 23, 2009 08:32AM |
Registered: 16 years ago Posts: 2,075 Rating: 0 |
Re: Linker Errors March 23, 2009 05:16PM |
Registered: 18 years ago Posts: 1,424 Rating: 0 |
Language: C++... operator << <Type> (....)
Language: C++... operator<< (.....)
Language: C++#include <iostream> using namespace std; // class and function prototypes template <typename Type> class MyClass; template <typename Type> std::ostream& operator<<(std::ostream &sout, const MyClass<Type> &list); // class template definition template <typename Type> class MyClass { friend std::ostream& operator<< <Type>(std::ostream &sout, const MyClass<Type> &list); public: MyClass(Type value):m_value(value){} private: Type m_value; }; // function template definition template <typename Type> std::ostream& operator<<(std::ostream &sout, const MyClass<Type> &list){ sout << list.m_value; return sout; } // main program entry point int main(int argc, char **argv){ MyClass<int> list(7); // Compiler instantiates "MyClass<int>" in the background using the "MyClass<Type>" template to work from and replacing "Type" with "int" cout << list << endl; // Compiler instantiates "ostream &operator<< (ostream &, MyClass<int> &)" in the background using the "ostream &operator <<(ostream &, MyClass<Type>)" template return 0; }
Re: Linker Errors March 24, 2009 01:25PM |
Registered: 16 years ago Posts: 2,075 Rating: 0 |
Re: Linker Errors March 24, 2009 01:45PM |
Registered: 18 years ago Posts: 560 Rating: 2 |
Re: Linker Errors March 24, 2009 01:59PM |
Registered: 18 years ago Posts: 1,424 Rating: 0 |
Re: Linker Errors April 06, 2009 10:31AM |
Registered: 18 years ago Posts: 560 Rating: 2 |