View Single Post

Kode

#include <iostream>
#include <cstring>
using namespace std;

const int LEN = 20;
class Objekt {
private:
 char txt[LEN];
 char tegn;
 int tall;

public:
 Objekt(char tx[], char te, int ta)
{ strcpy(txt, tx); tegn = te; tall = ta; }
 void funk1() { cout << txt << ' ' << tegn << ' ' << tall; }
 bool funk2(char te, int n1, int n2)
{ return (txt[n1] == te || txt[n2] == te); }
 char funk3() { return (char(int(tegn) + tall)); }
 void funk4(int ta) { tall = ta; }
};

int main() {
Objekt ob1("Arsenal", 'A', 5), ob2("Chelsea", 'H', 3);
cout << ob2.funk2('e', 3, 6) << '\n';     // Utskrift:
cout << ob1.funk2('a', 0, 5) << ' ' << ob2.funk2('E', 2, 5) << '\n'; // Utskrift: 
ob2.funk4(-7); cout << ob1.funk2(ob2.funk3(), 0, 1) << '\n'; // Utskrift: 
return 0;
}
Jeg har fasit men det hjelper lite.

Jeg slite med framgangsmåten i hodet