#include <iostream> #include <cstdlib> #include <locale.h> using namespace std; #define PI 3.14 class sphere{ public : double radius; sphere(double r){ radius=r; cout<<"Yap�l�yor.."<<endl; } sphere() { sphere(1); } ~sphere(){ cout<<"Y�k�l�yor.."<<endl; } double get_volume(){ return (4/3)*PI*radius*radius*radius; } }; int main0402(){ setlocale(LC_ALL,"Turkish"); sphere *s1; s1=(sphere *) malloc( sizeof(sphere) ); s1->radius=3; cout<<"Yar��ap : "<<s1->radius<<endl; cout<<"Oylum : "<<s1->get_volume()<<endl; free(s1); sphere *s2; s2=new sphere(3); cout<<"Yar��ap : "<<s2->radius<<endl; cout<<"Oylum : "<<s2->get_volume()<<endl; delete s2; sphere *array=new sphere[3]; array[0].radius=3; cout<<"Yar��ap : "<<array[0].radius<<endl; cout<<"Oylum : "<<array[0].get_volume()<<endl; delete [] array; sphere **pointers=new sphere*[3]; pointers[0]=new sphere(3); cout<<"Yar��ap : " <<pointers[0]->radius<<endl; cout<<"Oylum : " <<pointers[0]->get_volume()<<endl; delete pointers[0]; delete pointers; return 0; }Dosyayı İndir