Jump to content

BST e classes duvida ( again )


Recommended Posts

#include <iostream>
#include <string>
#include "BST.H"
using namespace std;

class PalavraFreq {
string palavra;
int frequencia; // frequencia = nº de vezes que palavra aparece
PalavraFreq(string p=""): palavra(p), frequencia(0) {}
string getPalavra() const { return palavra; }
int getFrequencia() const { return frequencia; }
void setFrequencia(int f) { frequencia=f; }
bool operator < (const PalavraFreq &pf1) const
{ return palavra < pf1.palavra; }
bool operator == (const PalavraFreq &pf1) const
{ return palavra == pf1.palavra; }

class AnaliseTexto {
BST<PalavraFreq> palavras;
void trataTexto(string texto);
int compMedio() const;
string maisFrequente(string pref) const;
void listarEntre(string pal1, string pal2) const;

void AnaliseTexto::trataTexto(string texto)
     PalavraFreq NOT_FOUND;
    int pos=texto.find(" ");
    string palavra = texto.substr(0,pos);
           PalavraFreq aux = palavras.find(palavra);
    texto = texto.substr(pos+1);
    pos=texto.find(" ");

Pll basicamente estou com uma duvida estupida  ?

Pll desta maneira estou a usar a variavel BST<PalavraFreq> palavras na funçao tratatexto, Mesmo ela sendo PRIVADA?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.