help-gplusplus
[Top][All Lists]
Advanced

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

Re: Default argument in class member function


From: Paul Pluzhnikov
Subject: Re: Default argument in class member function
Date: Thu, 27 Oct 2005 13:45:39 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)

Long Li <lilong76@yahoo.com.cn> writes:

> class da{
> public:
>   void printargu( int a = 0 );
> };
>
> void da::printargu( int a = 0 ){
>   cout << a << endl;
> }

That isn't valid C++. 
You can only specify default argument *once* (and only in the first
declaration of the function).

Correct code:

  class da {
  public:
    void printargu(int a = 0);
  };
  void da::printargu(int a) {
    cout << a << endl;
  }

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.


reply via email to

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