C++ (Qt)namespace MySpace{ QString getStr() { QString str; //... return str; }}
C++ (Qt)namespace MySpace{ QString getStr();}
C++ (Qt)class SomeClass{ public: template<class T> void Fun(T* pT);};
C++ (Qt)template void SomeClass::Fun<int>(int*); //тип 1template void SomeClass::Fun<double>(double*);//тип 2template<class T> void SomeClass::Fun(T* pT){ //...}
C++ (Qt)#ifndef SOMECLASS_H#define SOMECLASS_H class SomeClass{public: template<class T> void Fun(T pT);}; #endif
C++ (Qt)#include <iostream>#include "SomeClass.h" template void SomeClass::Fun<int>(int); //тип 1template void SomeClass::Fun<double>(double);//тип 2template<class T> void SomeClass::Fun(T pT){ std::cout << pT << std::flush;}
C++ (Qt)#ifndef MYCLASS1_H#define MYCLASS1_H class SomeClass; class MyClass1 {public: MyClass1(); SomeClass* t_member;}; #endif
C++ (Qt)#include "MyClass1.h"#include "SomeClass.h" MyClass1::MyClass1(): t_member(new SomeClass) { }
C++ (Qt)#include "MyClass1.h"#include "SomeClass.h" int main(){ MyClass1 class1; class1.t_member->Fun<int>(111);}