I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
Index » Programming » C/C++ »

Need help on this code

chapz\′s Photo
8 Jan 07, 5:58AM
(2 replies)
Need help on this code
class a
 
{
 
int b(int);
 
}
int a()::int b(int c)const
{
 
}
 
 
Can any one tell me what does "const" here stands for.
 
Regards
 
chapz\n
john\′s Photo
10 Jan 07, 9:13AM
Are you sure you've got that code right? I think your backets may by miss-positioned. For a start a class should usually finish with a ';', unless you're declaring a type thereafter.

As for const. I think what you have is int a() is the functioning with of class a. Therefore by placing const at the end of the line, you saying that the member function a (also the constructor since they have the same name), won't change any other elements within class a. Which is rather odd for a constructor.

However

::int(int c)

would be illegal if this was a member function, I would expect to see something more like this:

int a(int c)::b(c) const

But even that would be illegal, since constructors can't return data like this - there set up to return a pointer to the newly created class!!

So now I'm well confused. Where did you find this code?

John
chapz\′s Photo
10 Jan 07, 10:59AM
hi,

I was asked this code and it was the same ,

if i give cost at the end so that mean sit is constructor is it so.

Regardschapz
Currently you need to be logged in to leave a message.