I have a header file.
#include <iostream>

 class coinReturn
 {
 public:
     coinReturn();
     coinReturn(int quarters, int dimes, int nickels, int pennies);
     void setChange(int quarters, int dimes, int nickels, int pennies);
     void getChange(int& quarters, int& dimes, int& nickels, int& pennies);
     void print ();

 private:
    int countQuarters;
    int countDimes;
    int countNickels;
    int countPennies;
    double totalQuarters;

 };

an implementation file
#include <iostream>
#include "change.h"

 using namespace std;

 coinReturn::coinReturn()
 {
     countQuarters = 0;
     countDimes = 0;
     countNickels = 0;
     countPennies = 0;
 }

 coinReturn::coinReturn(int quarters, int dimes, int nickels, int pennies)
 {
     setChange(quarters, dimes, nickels, pennies);
 }

 void coinReturn::getChange(int& quarters, int& dimes, int& nickels, int& pennies)//output. returns a value
 {
     quarters = countQuarters;
     dimes = countDimes;
     nickels = countNickels;
     pennies = countPennies;


 }

 void coinReturn::setChange(int quarters, int dimes, int nickels, int pennies)//input
{
     countQuarters += quarters;
     countDimes += dimes;
     countNickels += nickels;
     countPennies += pennies;


 }

 void totalChange(int countQuarters, int dimes, int nickels, int pennies)// which one is correct countQuarters or quarters?
 {
     double totalQuarters;

     totalQuarters = countQuarters * .25;// where do i declare this?

 }

 void coinReturn::print()
 {
     cout << "Quarters " << countQuarters << endl;
     cout << "Dimes " << countDimes << endl;
     cout << "Nickels " << countNickels << endl;
     cout << "Pennies " << countPennies << endl;
     cout << totalQuarters << endl; //how do i get it to output?

 }

and a driver file
#include <iostream>
#include "change.h"

 void loadChange(int& quarters, int& dimes, int& nickels, int& pennies);

 int quarters;
 int dimes;
 int nickels;
 int pennies;

 using namespace std;
 int main()
 {
     coinReturn myReturn;

     loadChange(quarters, dimes, nickels, pennies);
     myReturn.setChange(quarters, dimes, nickels, pennies);
     myReturn.print();


     loadChange(quarters, dimes, nickels, pennies);
     myReturn.setChange(quarters, dimes, nickels, pennies);
     myReturn.print();
 }

 void loadChange(int& quarters, int& dimes, int& nickels, int& pennies)
     {
         coinReturn myReturn;

         cout << "Please enter number of quarters " << endl;
         cin >> quarters;
         cout << "Please enter number of dimes " << endl;
         cin >> dimes;
         cout << "Please enter number of nickels " << endl;
         cin >> nickels;
         cout << "Please enter number of pennies " << endl;
         cin >> pennies;

     }

My first question is in the imp file in the print function, how do i get totalQuarters to print. I plan on using this function for each coin. My second question is which way do I pass objects in the function, do i call the set or the get object?
Code blocks are created by indenting at least 4 spaces
... and can span multiple lines

Code blocks are created by indenting at least 4 spaces
... and can span multiple lines

Or just start the code in ~~~ and end with ~~~. You don't have to manually indenmt the code that way

//how do i get it to output?

I don't understand the question. That line should output the value of totalQuarters ok. Maybe you should post an example of what you want the program to display.

[edit]Test -- ignore this

/input

Please enter number of quarters
1
please enter number of dimes
1
please enter number of nickels
1
please enter number of pennies

/input

/ouput

Quarters
1
Dimes
1
NIckels
1
Pennies
1
.25 this shows 0 right now

/output

Something isnt getting passes somewhere, but I don't know where.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.