#include <iostream>
using namespace std;
class String
{
public :
String :: String(char* ch);
public : ~String ();
private :
char* text;
size_t sizeoftext;
public : void imprimircadena();
};
String :: String (char* ch)
{
sizeoftext = strlen(ch);
//pido la cantidad de memoria correcta para el string
text = new char[sizeoftext];
for (int i=0;i<=sizeoftext-1;i++)
{
text[i] = ch[i];
}
}
String :: ~String()
{
delete[] text;
};
void :: String imprimircadena() //problem is here
{
for (int i = 0 ; i < sizeoftext ; i++)
cout>> text[i];
cout>>endl;
};
int main()
{
String *obj1 = new String("palabra");
obj1->imprimircadena();
obj1->~String();
return 0;
};
the problem is at method imprimircadena(), what could it be?
The compiler gives me the error:
expected initializer before "imprimircadena".