By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,084 Members | 1,956 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,084 IT Pros & Developers. It's quick & easy.

Declaration of s specific return-type of method, outside the class-definition. How ?

P: 2
How do i declare a method that returns a doublepointer to a subclass, outside the Class-definition ?

That is, as of now I have
Expand|Select|Wrap|Line Numbers
  1. Class House
  2. {
  3.      ...
  4.      ...
  5.      Class Room
  6.      {
  7.          ...
  8.       }
  9.  
  10.       Room** myfunction(args)
  11.      {
  12.         Room **foo;
  13.         ...
  14.        return foo;
  15.      }
  16. }
  17.  
I would like to be able to move the myfunction outside the class-definition as usual; according to
Expand|Select|Wrap|Line Numbers
  1. Room** House::myfunction(args)
  2. {
  3.      Room **foo
  4.      ...
  5.      return foo;
  6. }
  7.  
But the compiler complains.

How do you write the declarations when it is not some of the traditional return types as void, int, float etc. ?
Jun 17 '07 #1
Share this Question
Share on Google+
2 Replies


Expert 10K+
P: 11,448
How do i declare a method that returns a doublepointer to a subclass, outside the Class-definition ?

That is, as of now I have
Expand|Select|Wrap|Line Numbers
  1. Class House
  2. {
  3.      ...
  4.      ...
  5.      Class Room
  6.      {
  7.          ...
  8.       }
  9.  
  10.       Room** myfunction(args)
  11.      {
  12.         Room **foo;
  13.         ...
  14.        return foo;
  15.      }
  16. }
  17.  
I would like to be able to move the myfunction outside the class-definition as usual; according to
Expand|Select|Wrap|Line Numbers
  1. Room** House::myfunction(args)
  2. {
  3.      Room **foo
  4.      ...
  5.      return foo;
  6. }
  7.  
But the compiler complains.

How do you write the declarations when it is not some of the traditional return types as void, int, float etc. ?
Room is a class in the scope of the House class so outside your class definitions
it would be this:

Expand|Select|Wrap|Line Numbers
  1. House::Room** House::myfunction( ...) // etc
  2.  
(I didn't look closely though, so I could be wrong; it's Sunday ;-)

kind regards,

Jos
Jun 17 '07 #2

P: 2
Ahh ok. Thanks, that worked !
Jun 17 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.