Ver Mensaje Individual
  #2 (permalink)  
Antiguo 26/11/2010, 11:45
nosek159
 
Fecha de Ingreso: octubre-2008
Mensajes: 118
Antigüedad: 15 años, 7 meses
Puntos: 2
Respuesta: Problema Clases (basico)

Lo he copiado todo en el main.cpp y funciona perfecto :S no lo entiendo
y si lo compilo por linea de comandos tmb me funciona pero desde el IDE no :S utilizo el Code::Blocks 10.05. Alguien sabe a que se debe?

Código:
#include <iostream>
#include <string>
#include <string>

using namespace std;

class MiClase
{
    private:
        string texto;
    public:
        MiClase(string algo);
        void asignarTexto(string txt);
        string mostrarTexto() const;

};


MiClase::MiClase(string algo):
texto(algo)
{
    cout << texto << endl;
}

void MiClase::asignarTexto(string txt)
{
    texto=txt;
}
string MiClase::mostrarTexto() const
{
    cout << texto << endl;
    return texto;
}

int main()
{
    string algo="hola";
    MiClase miClase(algo);
    cout << miClase.mostrarTexto() << endl;
    miClase.asignarTexto("adios");
    cout << miClase.mostrarTexto() << endl;
    return 0;
}