Thread: Class constructor

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    67

    Question Class constructor

    Hello, I am trying to have the constructor for a class use the address of the object being created..

    e.g.

    Code:
    class test
    {
         test()
         {
               someFn(&this_object);
         }
    }
    
    test hello;
    how do I do that? &this doesn't work.

    thanks

    Edit: this is an address, so no need for the ampersand. Problem solved.
    Last edited by RobotGymnast; 09-22-2008 at 05:38 PM.

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Edit: this is an address, so no need for the ampersand. Problem solved.
    And no need to pass the object to the constructor
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I don't believe he was wanting to pass the object to the constructor. I think he was instead wanting to pass this to a function.

  4. #4
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Oh, yes. My bad.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. deriving classes
    By l2u in forum C++ Programming
    Replies: 12
    Last Post: 01-15-2007, 05:01 PM
  3. template class default constructor problem
    By kocika73 in forum C++ Programming
    Replies: 3
    Last Post: 04-22-2006, 09:42 PM
  4. Calling constructor of the base class of a derived class..
    By CaptainPenguin in forum C++ Programming
    Replies: 5
    Last Post: 02-19-2003, 01:47 PM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM