Write a program that declared a class with one integer data member and two member functions for input data and output data. Decide appropriate access modifiers for these members. Use this class in your program.
#include <iostream>
using namespace std;
class Test{
private:
int first;
public:
void setFirst(int n) {
first = n;
}
int getFirst()
{
return first;
}
};
int main(){
Test t;
t.setFirst(9);
cout<<" The value is \t"<<t.getFirst();
return 0;
}
Comments
Leave a comment