help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Reply: Default argument in class member function


From: Long Li
Subject: Reply: Default argument in class member function
Date: Fri, 28 Oct 2005 04:55:42 +0800 (CST)

> Second one:
> 
> #include <iostream>
> using std::cout;
> using std::endl;
> 
> class da{
> public:
>   void printargu( int a = 0 );
> };
> 
> void da::printargu( int a = 0 ){
>   cout << a << endl;
> }
> 
> int main(){
>   da.printargu();
> }
> 
 
sorry, in main() should be:
da daa;
daa.printargu();

but the errors of line 10 and line 7 are still
there.

> I can compile the first one and get the right
> result. 
> However, for the second one, there are errors:
> c.cpp:10: error: default argument given for
> parameter
> 1 of 'void da::printargu(int)'
> c.cpp:7: error: after previous specification in
> 'void
> da::printargu(int)'



        

        
                
___________________________________________________________ 
雅虎免费G邮箱-中国第一绝无垃圾邮件骚扰超大邮箱 
http://cn.mail.yahoo.com





reply via email to

[Prev in Thread] Current Thread [Next in Thread]