Skip to content

Instantly share code, notes, and snippets.

@marcoscastro
Created May 14, 2017 16:42
Show Gist options
  • Select an option

  • Save marcoscastro/6f7589e9dae44e680bab26afb2bd319c to your computer and use it in GitHub Desktop.

Select an option

Save marcoscastro/6f7589e9dae44e680bab26afb2bd319c to your computer and use it in GitHub Desktop.
C++ - String retorno
#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