Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

iterators

Name: Anonymous 2009-12-12 22:32

Hello.
In C++, I'm using an iterator to iterate through a vector of pointers.
How do I perform operations on the iterator?
I've tried several things but keep getting errors. This is where I get the error:

//In constructor of interface class
d_ClassA.push_back(new Class B(3)); //d_ClassA is a..                                     //std::vector<ClassA*>
...

//member-function in interface class
...
for (vector<ClassA*>::iterator i = 0; i != d_ClassA.end(); i++) {
    string classAFilename= (*i)->getFilename();
...

I guess there could be something else that is wrong. But is the code above correct?

Name: Anonymous 2009-12-12 22:37

OP here. sorry its
vector<ClassA*>::iterator i = d_ClassA.being()

Name: sage 2009-12-12 23:07

keep getting errors
not posting the error message
9.5/10

Name: Anonymous 2009-12-14 2:02

>>3
In case you couldn't tell by looking, the error is 'Segmentation fault'.

Name: Anonymous 2009-12-14 2:12

>>4
No we cannot fuckin tell by looking.  Noobtards claim "halp i has error" all the time for any variety of error.  And nobody should have to tell by looking either; you need to help them help you if you want their advice that badly.

Name: Anonymous 2009-12-14 2:12

>>1
It's because you didn't use the [code] tags. But don't worry, there are enough tools here that will help you even though you didn't care to format your code.

Name: HMA 2009-12-14 4:26

>>4
>>3 here.
No, like >>5 said, we can't tell by looking, the error isn't in this snippet, and you didn't even bother to say if it's compile-time or run-time.

What are you using as an IDE? If it's VC++, go in the debug menu, exceptions, and make it break whenever there's an exception (activate them all, who cares). If it's emacs or whatever, I don't debug Sepples with it so I don't know. Then check if the segfault is really when you dereference the iterator, or in your getFilename() call, or wherever. If you see a null pointer that shouldn't be null, use breakpoints. Put one at your call, check the integrity of your data structure and its content. Put one in the classb destructor and check when it gets destroyed. You know, what we call ``debugging''. The bug isn't caused by what you posted itself.
Also ヌルポ my anus

Name: ​​​​​​​​​​ 2010-10-26 8:09

Name: Anonymous 2010-12-20 19:01

Name: Anonymous 2011-02-04 13:13

Name: Anonymous 2013-08-31 22:54



     __,ヘ_ ,. -──- 、,
    ri::::;ヘ>===- 、 `ヽ.
 邪 7〉' ,  , ハ 、 `ヽ  ',
 魔 i i /_!,/ィ」 L、!_ハ_i ', i
 な  |_i__!イ'T,j   'T_,T!_ハ! |    それで満足したら
 ん   ! 7i"      ",!l | |     お帰り願えますか
 で.  | i l>.、.,_` _,,.イ! /l |      __
     ヽ!ヽヘレくレ'/レ'ヽ!' /〉 , '"´  `ヽ.
       /7}><{/:::/^ヽ.くx'/ /  ´・ ω・`!
      r〈/::::Y::::t::k' _,.ィ'×、> ,'       ,'     
      / k:::::i::::::::::i'´ !/ /      , '
   .ヘ、//::`7::T::: ̄!  |、 ,'      /
   `>'::::::::/:::::::::::::::::::!  |::ヽ.   , '"´
   rくe::::::/::::::::::i:::::::::::し_ノ::e::>、'
   ヽニヽ7ニ二ィ_T__ハ_7イノー'´〈
     `ゝ、_rン ^ヽ、_r、,ノ  `ヽi
      ,.イ--!   Y i、
     (二'ン'    〈'二_'〉
       ̄       ̄

Name: Anonymous 2013-09-01 0:25



::::::::::::::::::::::::::::::::::: :::::::: ::: :: : :
::::::::::::::::::::::::::::::: ::: :: : :
::::::::::: ::: :: : :  ,.  '"´ ̄ ̄`゙  ー- 、,
:::: ::: :: : :  , '´             `ヽ.
:: : : :  /   /   .           \
: :    /     /    ,|          、    ',
   _ノ     !メ、_,/ |  ,ハ  ∧|    |    |
    `'l ,!  / >ァ‐ト、!/  ∨ート、 /     !
     ∨|  /イ l ,rリ    'ーァテ'く|. /     !
    / |/ ○ ´ ̄  ,   l ,rハレ'L_  ,ハ
   /  o ゚ ,|    , -‐- 、 `'' ひ。r_,ノ   |
   !    .ノ ト,、   !/´ ̄ ハ   /´ O   /
   \ (  ノ .>、,    ノ , イ   i   /
    )'⌒ヽ>-‐rイ|`こて´_ノ ア ̄`ヽ(
      /、::::::::::ト、_[こン-‐<7::::::::::::::::/`7、
      〈Xヽ:::::::|X| ム ,-、.X/::::::::::::::::/X/ ハ     ,.、
      \X\:|/´l_/ ./、7::::::::::::::::/X/  _|  _/´l/ ,ハ
       |\ rイ ´    !::::::::::::::::/X//´ /´  '  /)
      ,r[_/|八     ノ|:::::::::!/、/,'/´「|    /´
      l>''´ ト、,_\‐イ|X|:::::::/|X/ /   ゝ'、__,. イ!
    /´       `ゝ_イ:!::/::::::::::レヘ |     `ー-'^ー' |

Name: Anonymous 2013-09-01 1:57



                _,,.. -‐─- 、..,,_
          _「ヽ┐'" ,. -─- 、..,,_   `'ヽ.
         rヘ:::ヽ::>'"´ ̄ ̄`"''- 、`' 、  ':,
         `ア、/ /        `ヽ.';   ',
          / /  / / /i   ,    、  '!  i
        ノ /  /|,ゝ!、/ ,'  ハ  i  i   i   |
         ^ヽ/,ハ ! ト |'〈 /,ァ;-='ニ、ハ  |. i |  
       _____くソ ,!,,' ゝ'  `  ト   ハ .|__,| | | __  ,. -‐-、
   ,. '"´ ̄ヽ  く/,ハ.    _'__  ゝ-'' / /__!,/ irソ´ [C] |
   !/´と_,.┴∠_,//ゝ、 !'´ `ヽ ",イ>'"´r'/   /  _「,. -‐'、
 /X゜/  i.  └!、   ./i>r--'‐ァ"/  r'7i  ン  ,〈、_______ノ
.〈\/   ヽ、.,_  `"'r/_ノ>く_,ゝ:::イ    Yj 〈.,____,.ヘ、ー--ン
 `'´         ̄ ´/::::::::7o´ヽ、,_ゝ、ニ二_!ンァ、.,___,,..>-''
             く::::::::/o::::::::::::::::::Y^' ー ''"    ___
      _,r'7`':::ー-r`へ/、::::::::::::::::::::::!    ,. '"´  `ヽ.
      |_l::c::::::::::/::::::::::`T'':::ー-rヘ.    /        i
      iヽ::::::::/::::::::::::::::::::!:::::::::::';::::',  ./       /
      `rヘ:::::::::::::::/:::::::::::::::::::::::::::::::::',/       /
       `k>:、;::/__:::::::::::::i::::::::::::::::::::i_____,,,... - ''"´
       / ヽ.,__ンー、!二7ニr-ァ、.,__::::;ゝ、
      .rヘ、__/     //ヽ、___,.r7ー'´
     /'ゝ、,ン      ´    ヽ、___〉、
     !、__/             ヽ.,__ノ

Name: Anonymous 2013-09-01 3:27



           ,..-─-、
          ,:'>--:::::::':.,
          /:::::::::::=ニ二\
         ;:::、:::::::::__;;;:::-<ム          何やらわからぬが
        ;'-‐,> ''"´ ̄ ̄`゙''  、
        {/        ヽ   ヽ、    お主は我の事を
      ,. -‐/   ./   {     }   ハ  ':,
    /   / ./ ;   ,ハ    ,ハノイ }  `ァ  ウ ス イ ホ ン
    { ∠;  ;  l. `メ _ ',.  , 'xァ=t、/  r'´    有珠異本とやらに
    ノ / {. ! /.ァ7示 }/  {r リハ  /
    ( /  ' ∨ l{八r_ソ   .  `"´,,{イハ    書き記すつもりだな?
    , '   ∧ {  \""   , --、  ,ム   }
   ./   /l人 '、  `ヽ、 、  ノ ,.イハ   /    そうであろう?
   ;  /   ヽ{ /`'=‐、 ハ` ー-r'i´}/ }/
   {   '、   /    ∨、ー-v'-}ト、
    \  ヽ./     } ;  ー=ム'  {\ __
     `' ァ'       | }  ,:'´:::::`:; ⊂二 ヽ
     ./       } '  '、::::::::::ノ '、ニニ ':,- 、
   /  - 、     /l}   `""´   |ヽ.,_ }}  ヽ
  /      ̄`゙'  、.//    ,:'"゙ヽ.   | | `||    ',
  {          \{.    '、;;_;;ノ    , .;   ||     }、
  /}` 、        ヽ         ∨ヽ. リ   ; \

Name: Anonymous 2013-09-01 13:45


I never got much into team sports, but I enjoy solo sports as a test of my own fitness and skill. I weightlift and I am hoping to get back into running once spring rolls around.

Name: Anonymous 2013-09-01 15:16





    I HATE NIGGERS

Don't change these.
Name: Email:
Entire Thread Thread List