由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - how to suppress the implicit conversion for type conversi
相关主题
请问一个implicit conversion的问题(C++)fortran中dm有什么特殊含义吗
one question about initializaiton listHelp: who has gcc 4.0 or higher
[合集] question on item15 in Effective C++请教几个C++问题
question regarding const function怎么搞的?
c++ operator overloading questiona string define question (c++)
so weird (转载)array allocation in c
Re: VC里面的stl支持是不是很弱?[合集] 又学了一招
which func will be called?C++ implicit typename的问题
相关话题的讨论汇总
话题: int话题: complex话题: conversi话题: conversion话题: suppress
进入Programming版参与讨论
1 (共1页)
l*****d
发帖数: 359
1
for example, define a class of complex numbers (use int for simplicity).
class complex_int{
public:
complex_int(int); // constructor 1
complex_int(int, int); // constructor 2
friend complex_int operator+(complex_int&,complex_int&); // friend operator+
operator int(){return real;} // ****conversion to int*****
void print_out(){cout << real << '+' << imag << "i\n";} // display the
complex number
private:
int real;
int imag;
};
if I define two complex_int a and b,
and do "b=a+2".
This is an ambiguo
1 (共1页)
进入Programming版参与讨论
相关主题
C++ implicit typename的问题c++ operator overloading question
gcc 编译的时候要包括 header source file 吗?so weird (转载)
a simple question about constructorRe: VC里面的stl支持是不是很弱?
[合集] c++的题which func will be called?
请问一个implicit conversion的问题(C++)fortran中dm有什么特殊含义吗
one question about initializaiton listHelp: who has gcc 4.0 or higher
[合集] question on item15 in Effective C++请教几个C++问题
question regarding const function怎么搞的?
相关话题的讨论汇总
话题: int话题: complex话题: conversi话题: conversion话题: suppress