首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

这段代码为什么编译不过?该如何处理

2012-02-08 
这段代码为什么编译不过??C/C++ code#include iostreamusing namespace stdtemplateclass type, int d

这段代码为什么编译不过??

C/C++ code
#include <iostream>using namespace std;template<class type, int dim>class point{public:    point() {};    point(type coords[dim]) {        for (int index = 0; index < dim; index ++) {            _coords[index] = coords[index];        }    }    type& operator[](int index) {        //assert(index < dim && index >= 0);        return _coords[index];    }    type operator[](int index) const {        return _coords[index];    }    //ostream& operator<<(ostream &os, const point<type, dim> &pt);    void print() {        cout << "point::print()\n" << endl;    }private:    type _coords[dim];};inline template<class type, int dim>ostream& operator<<(ostream &os, const point<type, dim> &pt){    os << "(";    for (int ix = 0; ix < dim-1; ix ++) {        os << pt[ix] << ",";    }    os << pt[dim-1];    os << ")";}void main(){    cout << "I'm in main" << endl;}


[解决办法]
亲,能贴编译报错的代码吗?方便后面的高手提起回帖的兴趣!

热点排行
Bad Request.