Home > front end >  How to proper set up a destructor in C with Xcode?
How to proper set up a destructor in C with Xcode?

Time:05-06

there is something that has been bugging me for a while. I cannot create a destructor using Xcode (with other IDEs like VS2021 that is no issue).

I get the error:

1. Constructor cannot be redeclared
2. Missing return type for function '˜Pointer'; did you mean the constructor name 'Pointer'?

If I try to declare outside of the class and uncomment the lines in *.cpp and *.hpp the errors get even crazier.

My Pointers.hpp is the following:

#ifndef Pointers_hpp
#define Pointers_hpp
#include <iostream>

class Pointer{

public:
    Pointer(void);
    ˜Pointer(void){};
    //˜Pointer(void);

};
#endif /* Pointers_hpp */

and my Pointers.cpp is this one:

#include "Pointers.hpp"

Pointer::Pointer(void){};
//Pointer::˜Pointer(void){};

After several research in the internet, I could not find a solution to that, could any one give me a light on this?

Many thanks in advance, Raphael

CodePudding user response:

Solved thanks to user4581301:

For those having the same problem I did. The issue here was the similarity between ˜ and ~

The correct one should be ~

If you are using MacBook Pro the short-key is Option-N.

  • Related