Hey,

My code was working great yesterday. I go to submit it and it's got this new error out of nowhere! It is 'class std::vector<long double>' has no member named '_'. It says instantiated from the line

vector <LD> matrix;

and then takes me to some code entitled stl_vector.h. it points me to this

if (this->_._M_finish != this->_M_impl._M_end_of_storage)
	  {
	    this->_M_impl.construct(this->_M_impl._M_finish, __x);
	    ++this->_M_impl._M_finish;
	  }
	else
	  _M_insert_aux(end(), __x);
      }

I have no idea what is going on! Why is this happening?? It was all ready to go. Please help!
Thank you

Where do you typedef it to LD? or is that just an abbreviation when you posted?

I typedef it before the class declaration and after namespace std;
But the error came up before i'd typedef'd it and hasn't changed since i've typedef'd it.

I'm not sure. Post your code as an attachment (using the advanced editor and uploading it).

I think you need to post the entire code, maybe you did something a little weird that upset the compiler. Otherwise, this shouldn't cause an error.

Ok i've attached it. Thank you.

Now that is weird. That is not my code. Something has happened, possibly because of the error or possibly because of me, one second.

ok this should be it.

Line 228

LD IFS::get_A(LD A)const
{
    return matrix[A];
}

You shouldn't have a long double as an index of a vector.

(there are a fair number of other warnings as well, which you should address)

partymild1.cpp:59:30: warning: "/*" within comment
partymild1.cpp:60:9: warning: "/*" within comment
partymild1.cpp: In member function `LD IFS::set_A(int, const LD&)':
partymild1.cpp:225: warning: control reaches end of non-void function
partymild1.cpp: In member function `LD IFS::get_A(LD) const':
partymild1.cpp:228: warning: passing `LD' for converting 1 of `typename _Alloc::
const_reference std::vector<_Tp, _Alloc>::operator[](size_t) const [with _Tp = L
D, _Alloc = std::allocator<LD>]'
partymild1.cpp: In function `IFS operator*(const IFS&, const IFS&)':
partymild1.cpp:256: warning: converting to `int' from `LD'
partymild1.cpp:257: warning: converting to `int' from `LD'
partymild1.cpp:258: warning: converting to `int' from `LD'
partymild1.cpp:259: warning: converting to `int' from `LD'
partymild1.cpp:260: warning: converting to `int' from `LD'
partymild1.cpp:261: warning: converting to `int' from `LD'
partymild1.cpp:262: warning: converting to `int' from `LD'
partymild1.cpp:263: warning: converting to `int' from `LD'
partymild1.cpp:264: warning: converting to `int' from `LD'
partymild1.cpp: In function `IFS operator+(const IFS&, const IFS&)':
partymild1.cpp:270: warning: converting to `int' from `LD'
partymild1.cpp:271: warning: converting to `int' from `LD'
partymild1.cpp:272: warning: converting to `int' from `LD'
partymild1.cpp:273: warning: converting to `int' from `LD'
partymild1.cpp:274: warning: converting to `int' from `LD'
partymild1.cpp:275: warning: converting to `int' from `LD'
partymild1.cpp:276: warning: converting to `int' from `LD'
partymild1.cpp:277: warning: converting to `int' from `LD'
partymild1.cpp:278: warning: converting to `int' from `LD'
partymild1.cpp: In function `IFS operator-(const IFS&, const IFS&)':
partymild1.cpp:285: warning: converting to `int' from `LD'
partymild1.cpp:286: warning: converting to `int' from `LD'
partymild1.cpp:287: warning: converting to `int' from `LD'
partymild1.cpp:288: warning: converting to `int' from `LD'
partymild1.cpp:289: warning: converting to `int' from `LD'
partymild1.cpp:290: warning: converting to `int' from `LD'
partymild1.cpp:291: warning: converting to `int' from `LD'
partymild1.cpp:292: warning: converting to `int' from `LD'
partymild1.cpp:293: warning: converting to `int' from `LD'

The first two are minor (nested comments) but you should investigate the rest too. These were found by compiling with the maximum warning level.

Why yes of course, thank you. I have changed that back to int. Unfortunately the error was there before i accidentally changed it when typedefing, and so it is still there now i've changed it back. Thanks for pointing that out though.

Oh wow, there are a lot of errors, huh? I think i've fixed some of the converting int to LD. How exactly is it you put on the maximum warning level so I can check? Thank you.

I'm not sure then, I'm not getting any error like that. Which compiler are you using? Sounds like Visual C++ if it's letting you step into the STL like that. Look and see if it's a known problem... otherwise, start a fresh program with just a vector initialized in it and see what happens.

I'm using code::blocks and g++. I now also get this error, does this shed any light?

'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = long double, _Alloc = std::allocator<long double>, value_type = long double]':|

Oh wow, there are a lot of errors, huh? I think i've fixed some of the converting int to LD. How exactly is it you put on the maximum warning level so I can check? Thank you.

Under:
project menu/<your proj name>properties/configurationproperties/CC++/warninglevel, change it to /W4

The only error I get when I compile it in VS (which only gives a warning in g++, oddly enough) is that you don't return a value from Set_A, which should be void anyway (or since you're doing some tests in it should return a bool)

Thanks. I think that I changed something when i exited codeblocks last, when it asked me if i wanted to save some changes (not to file). Because the old file actually still compiles. Any changes, even when they're good like changing the matrix index to int stops it from compiling. At least I'm hoping that may be the problem. Thanks for your help.

Yeah I noticed the void too and tried to change it but it just stops it from compiling. Lame.

Sorry, I didn't know you were using C::B, in that system to get the -Wall (assuming you use it with the gcc) it's under Project/ProjectBuildOptions/CompilerSettingsTab/CompilerFlags and Enable all compiler warnings should be checked.

Yeah I noticed the void too and tried to change it but it just stops it from compiling. Lame.

Just because it compiles doesn't mean it's correct lol. You probably didn't change it in both the declaration and the definition.

No i did. In fact I tried changing just the filename and even that stops it compiling.

Perhaps time to reinstall the whole shebang, lol.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.