g*s
2 楼
Three files:
complex.h
#ifndef COMPLEX_H
#define COMPLEX_H
#include
using namespace std;
template
class Complex{
friend ostream & operator <<(ostream &output, const Complex &rhs);
private:
T real;
T imaginary;
public:
explicit Complex(T x, T y):real(x),imaginary(y){}
~Complex(){}
Complex & operator +(const Complex &rhs) const;
.
.
.
};
#endif
complex.cpp
#include "complex.h"
using namespace std;
template
ostream & operator
complex.h
#ifndef COMPLEX_H
#define COMPLEX_H
#include
using namespace std;
template
class Complex{
friend ostream & operator <<
private:
T real;
T imaginary;
public:
explicit Complex(T x, T y):real(x),imaginary(y){}
~Complex(){}
Complex
.
.
.
};
#endif
complex.cpp
#include "complex.h"
using namespace std;
template
ostream & operator
P*e
3 楼
where did you get this code?
For templates, place all the non-inline member function definition in the .h
file. This seems contrary to ordinary, but for templates, those member
function will not be compiled and will be waiting for run-time type define.
I don't know if this will help, but at least, you can get something right.
rhs);
【在 g*******s 的大作中提到】
: Three files:
: complex.h
: #ifndef COMPLEX_H
: #define COMPLEX_H
: #include
: using namespace std;
: template
: class Complex{
: friend ostream & operator <<(ostream &output, const Complex &rhs);
: private:
For templates, place all the non-inline member function definition in the .h
file. This seems contrary to ordinary, but for templates, those member
function will not be compiled and will be waiting for run-time type define.
I don't know if this will help, but at least, you can get something right.
rhs);
【在 g*******s 的大作中提到】
: Three files:
: complex.h
: #ifndef COMPLEX_H
: #define COMPLEX_H
: #include
: using namespace std;
: template
: class Complex{
: friend ostream & operator <<
: private:
t*t
4 楼
"run-time type define"...
i don't think C++ provides this
.h
【在 P********e 的大作中提到】
: where did you get this code?
: For templates, place all the non-inline member function definition in the .h
: file. This seems contrary to ordinary, but for templates, those member
: function will not be compiled and will be waiting for run-time type define.
: I don't know if this will help, but at least, you can get something right.
:
: rhs);
i don't think C++ provides this
.h
【在 P********e 的大作中提到】
: where did you get this code?
: For templates, place all the non-inline member function definition in the .h
: file. This seems contrary to ordinary, but for templates, those member
: function will not be compiled and will be waiting for run-time type define.
: I don't know if this will help, but at least, you can get something right.
:
: rhs);
P*e
5 楼
I mean this,
complex
complex
g*s
6 楼
3x. i write these codes myself.
I was thinking to write them in a .cpp as usual but i fail
to know template function would be better put inside one .h file.
.h
【在 P********e 的大作中提到】
: where did you get this code?
: For templates, place all the non-inline member function definition in the .h
: file. This seems contrary to ordinary, but for templates, those member
: function will not be compiled and will be waiting for run-time type define.
: I don't know if this will help, but at least, you can get something right.
:
: rhs);
I was thinking to write them in a .cpp as usual but i fail
to know template function would be better put inside one .h file.
.h
【在 P********e 的大作中提到】
: where did you get this code?
: For templates, place all the non-inline member function definition in the .h
: file. This seems contrary to ordinary, but for templates, those member
: function will not be compiled and will be waiting for run-time type define.
: I don't know if this will help, but at least, you can get something right.
:
: rhs);
相关阅读
请问delete的问题如何在C里面call C++的routine呢多谢各位大侠C 和 C++ code 在不同的机器上有多大不同? error LNK2001:的错误如何改正?Visual C++ 如何高亮显示 括号匹配?问一个函数对象问题中国首台国产二百万亿次超级计算机正式发布 (转载)Div+Css做网页 (转载)java 里可以插入linux command吗? (转载)请教大家一个directx显卡输出格式的问题.请问关于函数的局部变量如何从excel以特定格式导出数据到word? (转载)An algorithm questionC/C++ ferror()的返回值问题定义的struct数组很大时,为什么会出现奇怪的大数字?Watch out for list(dict.keys()) in Python 3 (zz)somebody used logsys before?有大侠讲讲RTTI和exception的问题么?什么是Linux 上最好的C programming environment?