0

I used Eclipse for Java development before, so I decided to try it with C++. After setting up my project in CDT, I had errors everywhere saying "Type so-and-so could not be resolved". I decided to make a test Hello World project, and got similar errors with anything else I added to it. For example:

enter image description here

Strangely enough, adding the scope resolution operator makes the error disappear and it works normally. I haven't done anything strange to the IDE; this is its out-of-box behavior on my system. Any idea what's wrong?

Raiden Worley
  • 394
  • 1
  • 4
  • 14
  • 1
    I suggest you make peace with Eclipse and use `std::` and remove the `using namespace std`. – Thomas Matthews Jan 09 '18 at 01:38
  • @ThomasMatthews That wouldn't be a problem except the same thing seems to be happening everywhere. Having to type boost::asio::socket_base::receive_buffer_size 20 times, for example, would be pretty rough. – Raiden Worley Jan 09 '18 at 01:43
  • 1
    `vector` is a template. You need to specialize it (`vector` for example). By the way, you have a vexing parse there. More on that bit of nastiness here: [Most vexing parse: why doesn't A a(()); work?](https://stackoverflow.com/questions/1424510/most-vexing-parse-why-doesnt-a-a-work) – user4581301 Jan 09 '18 at 01:47
  • @user4581301 Wow I can't believe I was doing something as stupid as not specializing the template and then thinking something was wrong. Thanks a bunch. – Raiden Worley Jan 09 '18 at 01:49
  • No worries. It is a pretty misleading error message. If you'd compiled you would have seen a better message like "missing template arguments". – user4581301 Jan 09 '18 at 01:53
  • You really ought to avoid `using namespace std` - it is a bad habit to get into, and [can silently change the meaning of your program](/q/1452721) when you're not expecting it. Get used to using the namespace prefix (`std` is intentionally very short), or importing *just the names you need* into the *smallest reasonable scope*. – Toby Speight Jan 09 '18 at 13:19

1 Answers1

0

As per @user4581301, I wasn't specializing my template.

Raiden Worley
  • 394
  • 1
  • 4
  • 14