+skyler_sdf Posted June 24, 2012 Report Posted June 24, 2012 Putem declara pointeri la clase. Acestia pot accesa date si metode din clasa respectiva. #include<math.h> class complex { public: float x, y; float modul(); }; float complex::modul() { return sqrt(x*x+y*y); } #include<iostream> #include "complex.cpp" using namespace std; int main() { complex *next=new complex; //obs ca este instantiat din clasa de baza next->x=9; next->y=2; cout<<next->modul()<<" "; delete next; system("PAUSE"); return 0; }
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now