在代码:构造被调用两次
//file main.cpp
LINT a = "12";
LINT b = 3;
a = "3";//WHY THIS LINE INVOKES CTOR?
std::string t = "1";
//LINT a = t;//Err NO SUITABLE CONV FROM STRING TO LINT. Shouldn't ctor do it?
//file LINT.h
#pragma once
#include "LINT_rep.h"
class LINT
{
private:
typedef LINT_rep value_type;
const value_type* my_data_;
template<class T>
void init_(const T&);
public:
LINT(const char* = 0);
LINT(const std::string&);
LINT(const LINT&);
LINT(const long_long&);
LINT& operator=(const LINT&);
virtual ~LINT(void);
LINT operator+()const; //DONE
LINT operator+(const LINT&)const;//DONE
LINT operator-()const; //DONE
LINT operator-(const LINT&)const;//DONE
LINT operator*(const LINT&)const;//DONE
LINT operator/(const LINT&)const;///WAITS FOR APPROVAL
LINT& operator+=(const LINT&);//DONE
LINT& operator-=(const LINT&);//DONE
LINT& operator*=(const LINT&);//DONE
LINT operator/=(const LINT&);///WAITS FOR APPROVAL
};
在被调用行号3,而不是分配optor构造函数。为什么?我愿意在某些服务器上卸载整个解决方案,否则很难将所有内容都放在这里。我也可以上传视频文件。另一件事是,当我实现这个任务optor我得到一个错误,这optor已经在obj文件?这是怎么回事?
你可以发布你的“=” - 运营商的实施? – Simon 2010-06-03 11:38:24
什么是LINT?为什么在'#pragma once'和'#include'之前LINT a =“12”'?从任何函数中改变一个变量是不可能的。 – 2010-06-03 11:39:50
@Alexey Malistov对不起我的错我应该提到这个代码来自两个不同的文件。去解决它; – 2010-06-03 11:47:42