#include <iostream>
#include <string>
using std::string;
class Palavra
{
private:
//int tamanho;
//string palavra;
public:
Palavra palavrasemelhante(const Palavra &p1, const Palavra &p2);
bool operator==(Palavra &p2);
const string getString();
string palavra;
};
//passar a arvore
Palavra Palavra::palavrasemelhante(const Palavra& p1, const Palavra& p2)
{
//se for igual as duas primeiras letras entao sao semelhantes
if(p1.palavra[0] == p2.palavra[0])
{
if(p1.palavra[1] == p2.palavra[1]){
return (p2);
}
}
return (p1);
}
const string Palavra::getString()
{
//retornar palavra para comparação de igual igual
return (this->palavra);
}
//sobrecarga de operador == para comparar dois objetos da classe Palavra
bool Palavra::operator == (Palavra &p2)
{
//palavra==p2.getstring ou desse jeitoif ( 0 == strcmp(palavra, p2.getString()))
if (palavra == p2.getString())
return (true);
else
return (false);
}
using namespace std;
int main()
{
Palavra p1;
Palavra p2;
p1.palavra = "abc";
p2.palavra = "Olani";
printf("%s, %s\n", p1.palavra.c_str(), p2.palavra.c_str());
return(0);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgoKdXNpbmcgc3RkOjpzdHJpbmc7CgpjbGFzcyBQYWxhdnJhCnsKICAgIHByaXZhdGU6CiAgICAgICAgLy9pbnQgdGFtYW5obzsKICAgICAgICAvL3N0cmluZyBwYWxhdnJhOwoKICAgIHB1YmxpYzoKICAgICAgICBQYWxhdnJhIHBhbGF2cmFzZW1lbGhhbnRlKGNvbnN0IFBhbGF2cmEgJnAxLCBjb25zdCBQYWxhdnJhICZwMik7CiAgICAgICAgYm9vbCBvcGVyYXRvcj09KFBhbGF2cmEgJnAyKTsKICAgICAgICBjb25zdCBzdHJpbmcgZ2V0U3RyaW5nKCk7CiAgICAgICAgc3RyaW5nIHBhbGF2cmE7Cn07CgovL3Bhc3NhciBhIGFydm9yZQpQYWxhdnJhIFBhbGF2cmE6OnBhbGF2cmFzZW1lbGhhbnRlKGNvbnN0IFBhbGF2cmEmIHAxLCBjb25zdCBQYWxhdnJhJiBwM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