/* Koen Noens * oef class * blz 256 opg 9.10 * opg 1 */ #include class Rechthoek { private : int breedte; int hoogte; public: Rechthoek(int br = 0, int ht = 0) //dit is de constructor { //argumenten van publieke fie doorgeven aan private members breedte=br; hoogte=ht; } void print(); }; void main() { Rechthoek R1(5,3); R1.print(); Rechthoek R2(15,5); R2.print(); } void Rechthoek :: print() { /* dit is dus de functie print() waarvan het prototype in Rechthoek staat * en die dus een method van Rechthoek is */ // bovenkant : for(int i = 0; i < breedte; i++) { cout << "x"; } cout << endl; //zijkanten for(i = 0; i < (hoogte-2); i++) { cout << "x"; for(int j = 0; j<(breedte-2);j++) { cout << " "; } cout << "x" << endl; } // onderkantkant : // is identiek aan bovenkant : aparte fie ? for(i = 0; i < breedte; i++) { cout << "x"; } //line feed cout << endl; }