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);
相关阅读
还是PERL问题Python API 下载google trend总是断掉怎么办? (转载)问几个关于网页和HTML的问题如何sort and merge n 个sorted linked listprogramming windows求教老美同事的站点: http://www.chatnearme.comtop 4 IT company interview question looking for answerLinux下C++如何快速返回超大文件的某一行字符串?有什么提高 RemoteDesktop 速度的 办法吗?template请教:记录访问者IP时,发生的奇怪问题!公司招人请教python 打开文件的问题!多谢!有python大神吗?紧急求助呀!!谢谢!!!赶快申办5%返现信用卡,开户就送$150!Oracle connection with walletfunction declaration免费送最高五晚酒店入住 任意消费一笔SPG 信用卡[c++] 关于构造函数的一个小问题Starwood Preferred Guest 最好的酒店和里程信用卡