Answer to Question #217367 in C++ for Fairy

Question #217367

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.


1
Expert's answer
2021-07-16T01:04:55-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS