Hi,

See these two small codes:

First one:

#include <iostream>
using std::cout;
using std::endl;

void printargu( int a = 0 ){
  cout << a << endl;
}

int main(){
  printargu();
}


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();
}

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)'
c.cpp: In function 'int main()':
c.cpp:15: error: expected unqualified-id before '.'
token

I just put the function "printargu" in the class in
the seond code, I can't understand it.  BTW, I use
g++-4.0 in Debian testing.

Long


        

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



_______________________________________________
Help-gplusplus mailing list
Help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to