Sorry for bothering, but I have a problem which I do not get.
I compiled a header file for a class and declared for Account() and getName() a constructor and a destructor in public. Background is that I want to close a external file with the desctructor.
The problem is now that the desctructor ~Account() does not provide any error; but the ~getName() provides "error: expected class-name before '(' token".
For me, it is just the same and it is only a declaration. I tried several things, but it does not change anything.
dtor is for the class at hand, in this case, account.
you rarely need explicit dtor: the compiler handles most object destruction for you cleanly. So the first question whether you need one or not should be examined, look up the rule of 3, rule of 5, and rule of zero. rule of 5 is a growth of the rule of 3 so those 2 are very similar.
so, not sure what your confusion is, but the string object in c++ already does its own destruction and you don't need any kind of destructor in your class to destroy this member; and in fact, you can't do that (but your class' destructor can call something itself if needed, so pretend you did need to destroy name string yourself: you could do it in your ~account() dtor. You don't need them for functions, that is something that has confused you).
~Account(); //this is correct, IF YOU NEED IT based off the rules I said.
the other stuff with a ~ in front of it is simply wrong: you have misunderstood the concept.