Here is my code, im trying to make my own string class but im stuck here... my teacher is not good :/ well i got so many errors but i want to know why this error appears "invalid preprocesing directive #ifndef_CADENA_H"
#include <iostream>
#include <cstdlib>
#ifndef_CADENA_H
#define_CADENA_H
class cadena {
char* Ptrcad;
int tam;
public :
cadena(void);
char* get(void);
void set(*char**)
int longitud;
~ Cadena (void);
};
Cadena :: Cadena(){
Ptrcad = NULL;
tam = 0;
}
char* Cadena :: get(){
return Ptrcad;
}
void Cadena :: set(const char* x){
while(*(x+tam)!='\0'){
tam++;
}
Ptrcad = new char (tam);
for(int i=0;i<tam;i++){
*(Ptrcad +i)= *(x+i);
}
}
int Cadena :: longitud(){
return tam;
}
Cadena :: ~ Cadena(){
delete [] Ptrcad;
tam =0;
}
Because of the underscore I believe. It should be #ifndef CADENA_H
and #define CADENA_H
. Unless you want to keep the underscore in the name (not reccommended in this case), then it should be #ifndef _CADENA_H
and #define _CADENA_H