Thread: two classes with methods that return each other by value

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    200
    Where exactly are you experiencing an issue? If it's just with getting the compiler to process it, you could use a forward declaration of Vector above Row - although I think you'll then have to return a pointer/reference instead of a fully-fledged object. Alternatively, declare them as functions outside of (and below) the class definitions and you can have them both return objects.

    On another note - why have you declared both transpose() methods to be static? If they both act on a single instance of their own class, it would make sense to make them both instance methods... no?

  2. #2
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    thanks anon and laserlight. this misconception had been kicking around for years, and it was only now that i had need to dispel it.

    Quote Originally Posted by JohnGraham View Post
    On another note - why have you declared both transpose() methods to be static? If they both act on a single instance of their own class, it would make sense to make them both instance methods... no?
    they are equivalent, i personally think the static function is cleaner syntactically, but it's just a matter of taste.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thoughts on return type from template container classes.
    By Subsonics in forum C++ Programming
    Replies: 17
    Last Post: 10-17-2010, 03:10 AM
  2. Can you inherit Methods into other methods?
    By bobbelPoP in forum C++ Programming
    Replies: 5
    Last Post: 08-02-2008, 08:32 AM
  3. call methods across classes
    By vb.bajpai in forum C++ Programming
    Replies: 11
    Last Post: 09-12-2007, 01:31 PM
  4. Replies: 6
    Last Post: 04-09-2006, 04:32 PM
  5. Replies: 8
    Last Post: 07-27-2003, 01:52 PM