Constructor is being invoked twice
Posted
by Knowing me knowing you
on Stack Overflow
See other posts from Stack Overflow
or by Knowing me knowing you
Published on 2010-06-03T11:34:35Z
Indexed on
2010/06/03
11:44 UTC
Read the original article
Hit count: 355
c++
In code:
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?
#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
};
in line number 3 instead of assignment optor ctor is invoked. Why? I'm willing to uppload entire solution on some server otherwise it's hard to put everything in here. I can also upload video file. Another thing is that when I implement this assignment optor I'm getting an error that this optor is already in obj file? What's going on?
© Stack Overflow or respective owner