Czy moglibyście rzucić okiem, może spróbować skompilować poniższy kod i powiedzieć co z nim jest nie tak? Wyrzuca mi błędy w implementacji klasy vector.
Kod: Zaznacz cały
[font=Monospace] [color=#c12dac]#[/color][color=#c12dac]include[/color][color=#c12dac]<[/color][color=#c12dac]iostream[/color][color=#c12dac]>[/color]
[color=#c12dac]#[/color][color=#c12dac]include[/color][color=#c12dac]<[/color][color=#c12dac]vector[/color][color=#c12dac]>[/color]
[color=#c12dac]#[/color][color=#c12dac]include[/color][color=#c12dac]<[/color][color=#c12dac]array[/color][color=#c12dac]>[/color]
[color=#c12dac]#[/color][color=#c12dac]include[/color][color=#c12dac]<[/color][color=#c12dac]algorithm[/color][color=#c12dac]>[/color]
[color=#999988][I]//[/I][/color][color=#999988][I]#[/I][/color][color=#999988][I]include[/I][/color][color=#999988][I]"[/I][/color][color=#999988][I]Instruction[/I][/color][color=#999988][I].[/I][/color][color=#999988][I]h[/I][/color][color=#999988][I]"[/I][/color]
[color=#999988][I]//[/I][/color][color=#999988][I]#[/I][/color][color=#999988][I]define[/I][/color][color=#999988][I]30000[/I][/color][color=#999988][I] SIZE[/I][/color]
[color=#009695]using[/color][color=#009695] namespace[/color][color=#444444] std;[/color]
[color=#999988][I]//[/I][/color][color=#999988][I]array[/I][/color][color=#999988][I]<[/I][/color][color=#999988][I]char[/I][/color][color=#999988][I],[/I][/color][color=#999988][I]SIZE[/I][/color][color=#999988][I]>[/I][/color][color=#999988][I]data[/I][/color][color=#999988][I];[/I][/color]
[color=#009695]class[/color][color=#444444] Instruction{[/color]
[color=#009695]public[/color][color=#444444]:[/color]
[color=#009695]virtual[/color][color=#009695]void[/color][color=#444444] execute()=0;[/color]
[color=#009695]virtual[/color][color=#444444] ~Instruction(){}[/color]
[color=#444444]};[/color]
[color=#009695]class[/color][color=#444444] Program : [/color][color=#009695]public[/color][color=#444444] Instruction{[/color]
[color=#009695]public[/color][color=#444444]:[/color]
[color=#444444] Program(vector<Instruction> v)[/color]
[color=#444444] {[/color]
[color=#444444] instructions = v;[/color]
[color=#444444] }[/color]
[color=#009695]void[/color][color=#444444] execute()[/color]
[color=#444444] {[/color]
[color=#009695]for[/color][color=#444444](size_t i=0; i<instructions.size(); i++) instructions.at(i).execute();[/color]
[color=#444444] }[/color]
[color=#009695]private[/color][color=#444444]:[/color]
[color=#444444] vector<Instruction> instructions;[/color]
[color=#444444]};[/color]
[color=#009695]class[/color][color=#444444] Loop : [/color][color=#009695]public[/color][color=#444444] Instruction{[/color]
[color=#009695]public[/color][color=#444444]:[/color]
[color=#444444] Loop(vector<Instruction> v)[/color]
[color=#444444] {[/color]
[color=#444444] instructions = v;[/color]
[color=#444444] }[/color]
[color=#009695]void[/color][color=#444444] execute()[/color]
[color=#444444] {[/color]
[color=#009695]for[/color][color=#444444](size_t i=0; i<instructions.size(); i++) instructions.at(i).execute();[/color]
[color=#444444] }[/color]
[color=#009695]private[/color][color=#444444]:[/color]
[color=#444444] vector<Instruction> instructions;[/color]
[color=#444444]};[/color]
[color=#009695]class[/color][color=#444444] Inc_pointer : [/color][color=#009695]public[/color][color=#444444] Instruction{[/color]
[color=#009695]public[/color][color=#444444]:[/color]
[color=#009695]void[/color][color=#444444] execute (){}[/color]
[color=#444444]};[/color]
[color=#009695]class[/color][color=#444444] Dec_pointer : [/color][color=#009695]public[/color][color=#444444] Instruction{[/color]
[color=#009695]public[/color][color=#444444]: [/color]
[color=#009695]void[/color][color=#444444] execute (){}[/color]
[color=#444444]};[/color]
[color=#009695]class[/color][color=#444444] Inc_value : [/color][color=#009695]public[/color][color=#444444] Instruction{[/color]
[color=#009695]public[/color][color=#444444]:[/color]
[color=#009695]void[/color][color=#444444] execute (){}[/color]
[color=#444444]};[/color]
[color=#009695]class[/color][color=#444444] Dec_value : [/color][color=#009695]public[/color][color=#444444] Instruction{[/color]
[color=#009695]public[/color][color=#444444]:[/color]
[color=#009695]void[/color][color=#444444] execute (){}[/color]
[color=#444444]};[/color]
[color=#009695]class[/color][color=#444444] Output : [/color][color=#009695]public[/color][color=#444444] Instruction{[/color]
[color=#009695]public[/color][color=#444444]:[/color]
[color=#009695]void[/color][color=#444444] execute (){}[/color]
[color=#444444]};[/color]
[color=#009695]class[/color][color=#444444] Input : [/color][color=#009695]public[/color][color=#444444] Instruction{[/color]
[color=#009695]public[/color][color=#444444]:[/color]
[color=#009695]void[/color][color=#444444] execute (){}[/color]
[color=#444444]};[/color]
[color=#009695]int[/color][color=#444444] main([/color][color=#009695]int[/color][color=#444444] argc, [/color][color=#009695]char[/color][color=#444444]* argv[])[/color]
[color=#444444]{[/color]
[color=#444444] cout << argv[0] << endl << argv[1] << endl << endl;[/color]
[color=#009695]return[/color][color=#444444] 0;[/color]
[color=#444444]}[/color][/font]
Miłego dnia. Pozdrawiam!
EDIT: Zagapiłem się i nie zastosowałem prawidłowej nomenklatury tematu. Jeśli mogę, proszę moderatora o zmianę tematu na 'C++ - kompilator wyrzuca błędy w standardowej implementacji vector'.
EDIT post EDIT: Ok, błąd został zlokalizowany. Otóż należało wywalić =0 z deklaracji funkcji wirtualnej. Wątek do zamknięcia jako rozwiązany.