Skip to content

Commit

Permalink
转换函数和重载的歧义问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee committed May 3, 2018
1 parent 2dfb72e commit 91b4df3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions chapter_10/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ int main(int agrs, char *argv[])
{
// class_test();
// class_this_test();
//class_operator_test();
class_operator_test();
//friend_test();
convert_function_test();
// convert_function_test();


cin.get();
Expand Down Expand Up @@ -117,6 +117,13 @@ void class_operator_test(void)
Stock stock1("Lee",1,1);
cout << "stock1:\n" << stock1;
}

// 由于存在转换函数这里将出现歧义,是先将stock1调用转换函数变成double类型,还是先将1.0转换成Stock对象调用重载函数
mycout();
{
Stock stock1("Lee",1,1);
// stock1 = stock1 + 1.0;
}
}

//friend友元函数测试,重载超过一个参数必须写成友元函数,而非成员函数
Expand Down

0 comments on commit 91b4df3

Please sign in to comment.