Macierze
Ostatnio zmodyfikowano 2008-10-30 17:07
Mapet Temat założony przez niniejszego użytkownika |
Macierze » 2008-10-30 16:25:22 Mój kod zawiera na razie samą klase która i tak sie nie che z kompilować. Nie mam pojecia co zrobilem zle. #include<iostream> #include<conio.h> using namespace std;
void klawiszologia( void );
class macierz { int wiersze; int kolumny; public: macierz( int Wiersze_, int Kolumny_ ) { wiersze = Wiersze_; kolumny = Kolumny_; int ** macierz = new int *[ wiersze ]; for( int i = 0; i < wiersze; i++ ) macierz[ i ] = new int[ kolumny ]; } macierz( int wiersze, int kolumny, int ** macierz ) { for( int i = 0; i < wiersze; i++ ) { for( int j = 0; j < kolumny; j++ ) { cout << "Podaj wartosc dla elementu : " << i << "." << j << " : "; cin >> macierz[ i ][ j ]; } } } ~macierz() { for( int i = 0; i < wiersze; i++ ) delete[]( macierz[ i ] ); delete[] macierz; } void pokaz_macierz( int wiersze, int kolumny, int ** macierze ) { for( int i = 0; i < wiersze; i++ ) { for( int j = 0; j < kolumny; j++ ) { cout << i << "." << j << " : " << macierz[ i ][ j ] << endl; } } } };
int main() { system( "pause" ); }
void klawiszologia( void ) { cout << "[ESC] - Wyjscie \t [H] - Pomoc \t [S] - Tworz macierz" << "\n[u] - Usun macierz \t [D] - Dzialania [P] - Klawiszologia" << endl; }
Bład jest w dekonstruktorze, wyskakuje mi ze problem z operatorem [] alebo cos takiego. Bede wdzeczny za szybką odpowiedz. |
|
DejaVu |
» 2008-10-30 16:39:59 Wklej log kompilacji - moim zdaniem może być problem z tym, że masz taką samą nazwę dla klasy jak i zmiennej w klasie. Mówisz, że masz błąd w destruktorze, ale on wygląda tak na oko poprawnie i błąd może wynikać z tego co napisałem. |
|
Mapet Temat założony przez niniejszego użytkownika |
» 2008-10-30 17:07:16 C:\Documents and Settings\Administrator\My Documents\Macierze (klasa).cpp In destructor `macierz::~macierz()': 32 C:\Documents and Settings\Administrator\My Documents\Macierze (klasa).cpp expected primary-expression before '[' token 33 C:\Documents and Settings\Administrator\My Documents\Macierze (klasa).cpp expected primary-expression before ';' token C:\Documents and Settings\Administrator\My Documents\Macierze (klasa).cpp In member function `void macierz::pokaz_macierz(int, int, int**)': 42 C:\Documents and Settings\Administrator\My Documents\Macierze (klasa).cpp expected primary-expression before '[' token
Sprawdzilem i miales racje problem tkwił w nazwie. Big thx. |
|
« 1 » |