Created
May 14, 2017 16:42
-
-
Save marcoscastro/6f7589e9dae44e680bab26afb2bd319c to your computer and use it in GitHub Desktop.
C++ - String retorno
This file contains hidden or 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
| #include <iostream> | |
| #include <string.h> | |
| using namespace std; | |
| class Pessoa | |
| { | |
| private: | |
| char nome[100]; | |
| public: | |
| Pessoa(char nome[100]) | |
| { | |
| strcpy(this->nome, nome); | |
| } | |
| char * obterNome() | |
| { | |
| return nome; | |
| } | |
| }; | |
| int main(int argc, char *argv[]) | |
| { | |
| char nome[100]; | |
| strcpy(nome, "Marcos Castro"); | |
| Pessoa p(nome); | |
| cout << p.obterNome() << endl; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment