This is the way that doesn't use constructors and destructors, I hope you find it useful.
#include <iostream>
class Fruit
{
private : int* no;
public : void initialize();
public : void clean();
public : int print_type();
};
void Fruit::initialize()
{
no = new int[ 3 ];
no[ 0 ] = 1;
no[ 1 ] = 2;
no[ 2 ] = 3;
}
int Fruit::print_type()
{
return no[ 0 ];
}
void Fruit::clean()
{
delete[] no;
}
int main()
{
Fruit f;
f.initialize();
int o = f.print_type();
std::cout << o;
f.clean();
return 0;
}