![]() |
Declaration of s specific type of method, outside the class-definition. How ?
How do i declare a method that returns a doublepointer to a subclass, outside the Class-definition ?
That is, as of now I have Code:
Class HouseCode:
Room** House::myfunction(args)How do you write the declarations when it is not some of the traditional return types as void, int, float etc. ? |
Re: Declaration of s specific type of method, outside the class-definition. How ?
You return it the same way, whether you define it "inside" the class or "outside".
"The compiler complains" is a crappy explanation. Exactly what is your compiler's complaint? If I were your compiler, I'd complain, too. The first example has "return Room" while the second has "return foo". Why don't you give us a small, but complete, snippet that fails. I mean real code. The real stuff the compiler doesn't like. Include with it the real reason that it fails. Neither we nor the compiler are mind readers, and I can't see your monitor from my house. |
Re: Declaration of s specific type of method, outside the class-definition. How ?
Quote:
It is how I should declare myfunction (the head) outside the Class by using ::. That is, Room ** House :: myfunction (...) <<<----- This line is wrong I suppose, wont work. { Room **foo ... return foo; } while normally if the function should return a int ** you can declare it as int ** House :: other_function (...) { int **foo; ... return foo;} Errors: error C2143: syntax error : missing ';' before '*' error C4430: missing type specifier - int assumed. Note: C++ does not support default-int error C4430: missing type specifier - int assumed. Note: C++ does not support default-int error C2556: 'int **House::myfunction(void)' : overloaded function differs only by return type from 'House::Room **House::myfunction(void)' see declaration of 'House::myfunction' 'House::myfunction' : redefinition; different basic types see declaration of 'House::myfunction' |
| All times are GMT +5.5. The time now is 06:40. |