Created
September 19, 2017 04:08
-
-
Save poanchen/d594efe13f0eac48396b2db052aeb808 to your computer and use it in GitHub Desktop.
Write a simple class that uses with a private variable and a public member function.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://repl.it/LECL | |
#include <iostream> | |
using namespace std; | |
class SimpleClass | |
{ | |
private: | |
string privateStr; | |
public: | |
void setPrivateStr(string text); | |
void printPrivateStr(); | |
}; | |
void SimpleClass::setPrivateStr(string text) | |
{ | |
privateStr = text; | |
} | |
void SimpleClass::printPrivateStr() | |
{ | |
cout << "privateStr is " + privateStr; | |
} | |
int main() | |
{ | |
SimpleClass sc; | |
sc.setPrivateStr("yo\n"); | |
sc.printPrivateStr(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment