Clase en C++

#include <iostream> using namespace std; class Rectangle { int width, height; public: void set_values (int,int); int area() {return width*height;} Rectangle(){} ~Rectangle(){} }; void Rectangle::set_values (int x, int y) { width = x; height = y; } int main () { Rectangle rect; rect.set_values (3,4); cout << "area: " << rect.area(); return 0; }

1 Response

1. Ver version:
gcc --version
gcc -v

2. Compilar:

gcc progr.cpp -o progr

3. Ejecutar:

4. Con g++

g++ progr.cpp -o progr.o

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.