online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
/* Se instancian multiples objetos de tipo LibretaDeNotas utilizando un constructor para definir el nombre del curso cuando cada objeto es creado. Crear Archivos para cada Libreta de Notas */ #include <iostream> #include <string> #include <iostream> #include <fstream> using namespace std; // Definicion de Clase LibretaDeNotas class LibretaDeNotas{ public: // El constructor. Inicializa la propiedad //nombreDelCurso con la cadena enviada como parametro LibretaDeNotas(string nombre){ // el constructor ofstream abre un archivo ofstream outClientFile( nombre+".txt", ios::out ); // Sale del programa si no puede crear el archivo if ( !outClientFile ){ // el operador ! negacion cerr << "El archivo no se puede abrir" << endl; exit( 1 ); } // end if setNombreCurso(nombre); // Establece el nombre outClientFile.close(); }// fin del constructor void setNombreCurso(string nombre){ nombreDelCurso=nombre; } string getNombreCurso(){ if( nombreDelCurso.length()==0 ) return " El Nombre no se ha establecido todavia "; return nombreDelCurso; } void insertNota (int nota){ ofstream outClientFile( nombreDelCurso +".txt", ios::app ); if ( !outClientFile ){ // el operador ! negacion cerr << "El archivo no se puede abrir" << endl; exit( 1 ); } // end if outClientFile<< nota << " "; outClientFile.close(); } string getNotas(){ string nota, linea; ifstream inClientFile( nombreDelCurso +".txt", ios::in ); if ( !inClientFile ){ // el operador ! negacion cerr << "El archivo no se puede abrir" << endl; exit( 1 ); } // end if while(inClientFile >> nota) { linea = linea+nota + " "; } inClientFile.close(); return(linea); } void mostrarMensaje(){ cout << "Bienvenido a la Libreta de Notas del curso " << getNombreCurso() << endl; } private: string nombreDelCurso; // Propiedad de la clase }; // fin de la clase LibretaDeNotas int main(){ // crear objetos tipo LibretaDeNotas LibretaDeNotas libretaDeNotas1("Fundamentos de Programación") ; LibretaDeNotas libretaDeNotas2("Programacion Orientada a Objetos") ; // Mostrar el nombre del curso para cada objeto creado cout<<"El curso para libretaDeNotas1 es: \n" <<libretaDeNotas1.getNombreCurso() << endl; cout<<"El curso para libretaDeNotas2 es: \n" <<libretaDeNotas2.getNombreCurso() << endl; libretaDeNotas1.insertNota(13); libretaDeNotas1.insertNota(15); cout<<"Las notas de libretaDeNotas1: " << libretaDeNotas1.getNotas(); }
13 15

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue