12 Mart 2010 Cuma

C++ Create Object with New

//www.ethemsulan.com
#include <cstdlib>
#include <iostream>
using namespace std;
class samp{
      int i,j;
      public:
             samp(int a,int b){i=a;j=b;}
             int get(){return i*j;}
      };
int main(int argc, char *argv[])
{
    samp *p;
    p=new samp(11,45);
    if(!p){
cout<<"bellekte yer ayirma hatasi\n";
           return 1;
           }
    cout<<"carpim: "<<p->get()<<endl;
    delete p;
    system("PAUSE");
    return EXIT_SUCCESS;
}

Hiç yorum yok:

Yorum Gönder