简体   繁体   中英

How to proper set up a destructor in C++ with Xcode?

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 inte.net, I could not find a solution to that, could any one give me a light on this?

Many thanks in advance, Raphael

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM