help with calling this setter

This is a discussion on help with calling this setter within the C++ Programming forums, part of the General Programming Boards category; void set_owner(string new_owner){owner = new_owner;} can someone tell me how to call this setter from main?? i wrote this, and ...

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    3

    Unhappy help with calling this setter

    void set_owner(string new_owner){owner = new_owner;}

    can someone tell me how to call this setter from main?? i wrote this, and i believe i wrote it correctly, but cannot call it...

    im trying to access owner from main, owner is a private member of a class....

    any help would be great, im stumped

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,497
    The set_owner needs to be a member function of that class
    And you need to indicate when you call it which class object you're going to be using

    myclass myobj;
    myobj.set_owner( "me" );
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stack issues when calling a COM library
    By notnot in forum C Programming
    Replies: 3
    Last Post: 06-01-2009, 02:12 AM
  2. calling functions within functions
    By edd1986 in forum C Programming
    Replies: 3
    Last Post: 03-29-2005, 02:35 AM
  3. calling default instead of argument constructor, why?!
    By cppn00b in forum C++ Programming
    Replies: 6
    Last Post: 01-30-2005, 03:24 AM
  4. calling conventions
    By Micko in forum C Programming
    Replies: 2
    Last Post: 07-18-2004, 09:13 AM
  5. Question on function syntax and calling function
    By cbrman in forum C Programming
    Replies: 10
    Last Post: 10-05-2003, 05:32 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21