#include <iostream>using namespace std; class test{ private: ~test() { cout<<"destrucor called"; } friend void desturct (test*);};void destruct (test *obj) { delete obj; cout<<"destrucor called1"; }int main() { test *obj = new test; destruct(obj); return 0;}
Standard input is empty
prog.cpp: In function ‘void destruct(test*)’: prog.cpp:15:10: error: ‘test::~test()’ is private within this context delete obj; ^~~ prog.cpp:7:2: note: declared private here ~test() ^
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!