Jump to content

Recommended Posts

Posted

Datele si metodele declarate public intr o clasa pot fi accesate de oriunde din program.

#include<iostream>

using namespace std;

class my_class

{


public:

	int i, j, k; //accesibile ptr tot programul


};

int main()

{


	my_class a, b;

	a.i=100;

	a.j=4;

	a.k=a.i*a.j;

	b.k=12; //ATENTIE, a.k si b.k sunt diferiti

  cout<<a.k<<" " <<b.k;

	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.