yes but in my program there is a function that adds six and seven together, so what i want to know is did i create it right so that the variables can be used outside of the class?
No, private variables can not be accessed outside its class. You should write either member functions that return its values or references to them or declare in the class some friend functions.
For example you could write a member function Add which will do what your want.
For example
1 2 3 4 5 6 7 8 9
class CLASS
{
public:
// your definitions are skipped for simplicity
int Add() const { return ( seven + six ); }private:
int seven;
int six;
};
ok but i dont want the function to add six and seven in the class i want it to do it outside of the class, which it already does and works. so what i want to know is am i doing it properly? the variables six and seven are in the class, there nowhere else in the program. The only thing that function2 does is output them to the screen. Here is my full code.