Speicherlimit auf Vista



  • ok, es funktioniert, ich verwende jetzt die klasse

    class picturergb{
    public:
    	unsigned int red[10][10];
    	unsigned int green[10][10];
    	unsigned int blue[10][10];
    };
    


  • jonnybx schrieb:

    ok, es funktioniert, ich verwende jetzt die klasse

    class picturergb{
    public:
    	unsigned int red[10][10];
    	unsigned int green[10][10];
    	unsigned int blue[10][10];
    };
    

    und?

    das hat aber nix mit deinem problem zu tun...



  • doch, aber ich hab den falschen code gepostet, natürlich sind die arrays [640][480], hier nochmal deer komplette code:

    #include <iostream>
    using namespace std;
    class picturergb{
    public:
    	unsigned int red[640][480];
    	unsigned int green[640][480];
    	unsigned int blue[640][480];
    };
    int main (void)
    {
    	char teststring;
    	cout << "press any key to start: \n(if you don't find any use j)";
    	cin >> teststring;
    	picturergb pic1();
    	picturergb pic2();
    	cout << "\ncreated two imagematrixes\n";
    	cout << sizeof(picturergb);
    	cin >> teststring;
    
    	return 0;
    }
    


  • Ein paar Anmerkungen:

    #include <iostream>
    using namespace std;
    class picturergb{ // Du hast nur public-Elemente, da tut es auch ein struct, sparst dir das public
    public:
    	unsigned int red[640][480];
    	unsigned int green[640][480];
    	unsigned int blue[640][480];
    };
    int main (void)  // void als Parameter ist unnötig, lass es weg.
    {
    	char teststring;
    	cout << "press any key to start: \n(if you don't find any use j)";
    	cin >> teststring;
    	picturergb pic1();  // lokale Funktionsdeklaration! pic1 ist kein Objekt, wie du vllt. denken könntest.
    	picturergb pic2();  // hier ebenso.
    	cout << "\ncreated two imagematrixes\n";
    	cout << sizeof(picturergb);
    	cin >> teststring;
    
    	return 0;
    }
    


  • *hust* Soweit wie ich C++ verstehe liegen deine Array trotzdem auf demm Stack.



  • Wenn ichs mit ner struct mach kommt trotzdem der stack overflow error:

    #include <iostream>
    using namespace std;
    struct picturergb{
    	unsigned int red[640][480];
    	unsigned int green[640][480];
    	unsigned int blue[640][480];
    };
    int main ()
    {
    	char teststring;
    	cout << "press any key to start: \n(if you don't find any use j)";
    	cin >> teststring;
    	picturergb pic1;
    	picturergb pic2;
    	cout << "\ncreated two imagematrixes\n";
    	cout << sizeof(picturergb);
    	cin >> teststring;
    
    	return 0;
    }
    

  • Mod

    jonnybx schrieb:

    Wenn ichs mit ner struct mach kommt trotzdem der stack overflow error:

    unskilled schrieb:

    jonnybx schrieb:

    ok, es funktioniert, ich verwende jetzt die klasse

    und?

    das hat aber nix mit deinem problem zu tun...



  • Zeig uns, die stelle wo du die Sachen auf dem Heap legst - so als tipp 😛



  • #include <iostream>
    using namespace std;
    struct picturergb{
    	unsigned int red[640][480];
    	unsigned int green[640][480];
    	unsigned int blue[640][480];
    };
    int main (void)
    {
    	char teststring;
    	cout << "press any key to start: \n(if you don't find any use j)\n";
    	cin >> teststring;
    	picturergb* pic1 = new picturergb; //pic1 im heap erstellt
    	picturergb* pic2 = new picturergb; //pic2 im heap erstellt
    	cout << "\ncreated two imagematrixes\n";
    	cout << sizeof(picturergb) << "\n";
    	delete pic1; //pic1 im heap gelöscht
    	delete pic2; //pic2 im heap gelöscht
    	cout << "pic 1 und pic 2 gelöscht\n";
    	cin >> teststring;
    	return 0;
    }
    

    mit dem code funktionierts jetzt.



  • hast du schon mal daran gedacht, auch ab und an ne zeile platz in deinem code zu lassen?

    #include <iostream>
    using namespace std;
    
    struct picturergb{
        unsigned int red[640][480];
        unsigned int green[640][480];
        unsigned int blue[640][480];
    };
    
    int main()
    

    bb



  • jetzt hab ich aber irgendwie das problem dass ich auf pic1.red[1][1] nicht zugreifen kann. kann mir mal bitte jemand die syntax dazu geben?



  • ja, klar:
    pic1->red[1][1]

    aber wenn wir dir hier alles erklären müssen, scheinst du noch mal dein c++-buch zur hand nehmen zu sollen - da scheinen ja nicht nur ein paar grundlagen zu fehlen...

    bb



  • Die Frage ist auch, warum du R, G und B nicht zusammenfasst. Dann brauchst du nämlich nur noch ein eindimensionales Array und kannst über sprechende Bezeichner auf die Farben zugreifen.


Anmelden zum Antworten