Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works

public methods help!

  • Please log in to reply



    New Member

  • Member
  • Pip
  • 1 posts
I have this program that uses more than one class and it needs to access the data from the first class of private data to the next class to use that data in sorting and such. Everyone says I need a public method to let it be accessible to the second class. Problem is, I cant find anything saying what the syntax is. and we're not allowed to use inheritance for this project

here is what I have for my second class

class Tournament:public Golfer
{ private:
int total_score[];

void compute_total();
void sort_name();
void final_score();


the golfer class has every golfer name and score in it. I just need to find a way for the tournament class to access the data. My project compiles and runs fine. it just dosent output the data sorted in the tournament class. The cout's in the tournament class work fine though.

Thank you
  • 0




    Member 1K

  • Member
  • PipPipPipPip
  • 1,382 posts
Hi Gster,
You can't access public methods of the Golfer directly, You need to create an object of the Golfer class in Tournament class.
A better way would be to use public static methods instead.

Edited by darth_ash, 06 April 2006 - 10:14 PM.

  • 0

Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP