Hola, pues apenas hoy, en plena víspera de Navidad aquí en México me decidí a instalar el Dev-C++ y a relizar una clase y un objeto que tengo como ejemplos en un libro de C++. Según basta con poner esto y me debe de compilar todo. El archivo fuente es este:
<br><br><div style="text-align: center; color: rgb(0, 0, 0);"><div style="text-align: left;"><span style="background-color: rgb(255, 255, 153);">#include <cstdlib></span><br style="background-color: rgb(255, 255, 153);">
<span style="background-color: rgb(255, 255, 153);">#include <iostream></span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">#include "stdafx.h</span><br style="background-color: rgb(255, 255, 153);">
<span style="background-color: rgb(255, 255, 153);">#include "TarjetaCredito.h"</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);"></span><br style="background-color: rgb(255, 255, 153);">
<span style="background-color: rgb(255, 255, 153);">#using <mscorlib.dll></span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">using namespace System;</span><br style="background-color: rgb(255, 255, 153);">
<span style="background-color: rgb(255, 255, 153);">using namespace std;</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);"></span><br style="background-color: rgb(255, 255, 153);">
<span style="background-color: rgb(255, 255, 153);">int main()</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">{</span><br style="background-color: rgb(255, 255, 153);">
<span style="background-color: rgb(255, 255, 153);">    TarjetaCredito *Mi_Cuenta;</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">    Mi_Cuenta = new TarjetaCredito;
</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">    Mi_Cuenta -> HacerCompra(100);</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">
    Mi_Cuenta -> Pagar(70);</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">    Mi_Cuenta -> Resultados();</span><br style="background-color: rgb(255, 255, 153);">
<span style="background-color: rgb(255, 255, 153);">    delete Mi_Cuenta;</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">    return 0;</span><br style="background-color: rgb(255, 255, 153);">
<span style="background-color: rgb(255, 255, 153);">}</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);"></span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">
bool TarjetaCredito::HacerCompra(double amount)</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">{</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">
     if (currentBalance + amount > creditLimit)</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">     {</span><br style="background-color: rgb(255, 255, 153);">
<span style="background-color: rgb(255, 255, 153);">                        return false;</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">     }</span><br style="background-color: rgb(255, 255, 153);">
<span style="background-color: rgb(255, 255, 153);">     else</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">     {</span><br style="background-color: rgb(255, 255, 153);">
<span style="background-color: rgb(255, 255, 153);">         currentBalance += amount;</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">         return true;</span>
<br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">     }</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">}</span>
<br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);"></span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">void TarjetaCredito::Pagar(double amount)
</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">{</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">     currentBalance -= amount;
</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">}</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);"></span>
<br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">void TarjetaCredito::Resultados()</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">
{</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">     Console::Write("Número de Cuenta");</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">
     Console::Writeline(numCuenta);</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">     </span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">
     Console::Write("Balance Actual");</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">     Console::Writeln(currentBalance);</span><br style="background-color: rgb(255, 255, 153);">
<span style="background-color: rgb(255, 255, 153);">}<br><br><span style="background-color: rgb(255, 255, 255);">Y el de el archivo de cabecera TarjetaCredito es el siguiente:<br><span style="background-color: rgb(255, 255, 153);">
<br>class TarjetaCredito</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">{</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">
      public:</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">             bool HacerCompra(double amount);</span><br style="background-color: rgb(255, 255, 153);">
<span style="background-color: rgb(255, 255, 153);">             void Pagar(double amount);</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">             void Resultados();
</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">      private:</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">
              long numCuenta;</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">              double currentBalance;</span><br style="background-color: rgb(255, 255, 153);">
<span style="background-color: rgb(255, 255, 153);">              double creditLimit;</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">}<br><br><span style="background-color: rgb(255, 255, 255);">
Podrían decirme en qué estoy mal? como digo, según el libro con eso basta para que el programa se compile pero me dan errores en las primeras lineas de include. Se supone que el programa debería ejecutar las funciones miembro de la clase TarjetaCredito y darme mal los datos de todas las variables miembro privadas ya que nunca las inicialicé y toman cualquier valor que esté en la memoria donde se encuentra el obejeto verdad?
<br><br>Otras preguntas:<br><br>Qué es API? Sé que es Application Programming Interface pero podrían darme ejemplos?<br><br>¿Cómo hago una clase administrada? En Visual Studio es con _gc antes del nombre de la clase, en todos los compiladores es igual? 
<br><br>¿La clase administrada me sirve para que los objetos se eliminen solos cuando ya no se necesiten? También sé que se crean en el CLR (Common Language Runtime) en vez de crearse en la pila y por tanto se tienen que crear objetos primero definiendo un puntero para poder almacenar la dirección de memoria del objeto.
<br><br>¿Cómo creo una clase no administrada? ¿Con _value antes del nombre de la clase? ¿Es igual para todos los compiladores?<br><br>¿Un puntero puede almacenar otro puntero? ¿En las clases administradas se supone que al crear un objeto se crea en tiempo de ejecución y en realidad devuelve un puntero que almacenamos en otro puntero?
<br><br>Ojalá y puedan ayudarme. Saludos desde México ;)<br></span></span><br><br></span></span></div><span></span></div>--------------------------<br> | = David Reza = |