Connecting Tech Pros Worldwide Forums | Help | Site Map

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

Newbie
 
Join Date: Jun 2007
Posts: 2
#1: Jun 17 '07
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. ?



JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#2: Jun 17 '07

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


Quote:

Originally Posted by KimRaver

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
Newbie
 
Join Date: Jun 2007
Posts: 2
#3: Jun 17 '07

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


Ahh ok. Thanks, that worked !
Reply