Can i use one function to make a private variable a public variable?

0 jb animated · June 8, 2015
Please check this code. In Bucky's tutorial, he used two function to make a private variable public. Is this code also a proper way to do it?

#include
#include
using namespace std;

class JbClass{

public:
    string setName(string x){
        name = x;
        return name;
    }

private:
    string name;

};

int main(){
    JbClass jo;
    cout

Post a Reply

Replies

Oldest  Newest  Rating
0 jb animated · July 4, 2015
thanks
  • 1

C++

107,003 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator