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);
相关阅读
见过的几个大牛关于小公司招人的问题,我的想法Design question: how to create installation package to covNest 成功的 key idea吐槽一下在国内招程序开发的郁闷 (转载)vs2013解释不了template, internal error 了, 哈哈Bing推出C#代码搜索插件php这个板上是不是声名狼藉蛋蛋这次被TW钓鱼成功goodbug继续嘴硬造谣,我视为PA长周末出去一趟,魏公公又冒头了?C++11和clang的很多新特性本质就是纵容新手酒驾求建议, mobile app devgoodbug你现在懂message queue了么?才发现gcc的parallel mode本站身家超过32亿美元的著名程序员魏老师 (转载)flappy birdatoi对我来说至少可以想出三种方式来做erlang系的东西从来都以量大著称请教一道新奇的面试题