File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
basic_content/const/class_const/overload_example Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change 22#include " apple.cpp"
33using namespace std ;
44const int Apple::apple_number=10 ;
5- Apple::Apple (int i)
5+ #include < iostream>
6+ #include " apple.cpp"
7+ using namespace std ;
8+
9+ Apple::Apple (int i):apple_number(i)
610{
711
812}
9- int Apple::add (int num){
10- take (num);
13+ int Apple::add (){
14+ take (1 );
15+ return 0 ;
1116}
1217int Apple::add (int num) const {
1318 take (num);
19+ return num;
1420}
1521void Apple::take (int num) const
1622{
@@ -19,14 +25,14 @@ void Apple::take(int num) const
1925int Apple::getCount () const
2026{
2127 take (1 );
22- // add(); // error
28+ add (); // error
2329 return apple_number;
2430}
2531int main (){
2632 Apple a (2 );
2733 cout<<a.getCount ()<<endl;
2834 a.add (10 );
29- const Apple b (3 );
30- b.add (100 );
35+ // const Apple b(3);
36+ // b.add(); // error
3137 return 0 ;
3238}
You can’t perform that action at this time.
0 commit comments