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);
相关阅读
求推荐Python 高阶读物到底怎么才算是用了open source的软件或编程语言?third party c/c++ code and compile it on win 7弱问一个virtual function的问题问一个设计模式的问题公司用硬盘 (转载)Q: 2 submit buttons in 1 page (转载)《Professional jQuery (第1版)》英文文字版/EPUB[PDF]Rebtel电话卡返校大促销,冲10刀送10刀求助MS.NET高手, WebAPI + WebDav (转载)非虚函数里调用虚函数无效?C++的"初始化"小结Amex SPG卡送25K points 免费500刀现金问个弱问题,C++为什么把interface和implementation分开?问一个defining array 的问题请教如何提高C++编程(面试)能力?师傅们,C++概念题,弟子有礼了这个PERL表达式干啥的?如果一个程序的makefile里-c改成-g就链接出错3d 图像库