Jump to content

Recommended Posts

Posted

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;

}

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.