Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / General / June 2005

Tip: Looking for answers? Try searching our database.

Using STL objects in default setup (VS .NET).

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Josh McFarlane - 08 Jun 2005 16:16 GMT
Ok, I've sat here and fought with the compiler for a while now.

I'm attempting to define a vector, but it keeps giving me a
'CRawData::vector' : missing storage-class or type specifiers
error for the line:
vector<float> vecElevationLeft                    ;    //Vector list of left elevation
samples

I figure I'm missing something fairly easy that is preventing me from
using stl::vector. Anyone care to clue me in on my stupidity?

Thanks,
Josh McFarlane
Jeff F - 08 Jun 2005 19:07 GMT
> Ok, I've sat here and fought with the compiler for a while now.
>
[quoted text clipped - 6 lines]
> I figure I'm missing something fairly easy that is preventing me from
> using stl::vector. Anyone care to clue me in on my stupidity?

#include <vector>

...

class CRawData
{
...

std::vector<float> vecElevationLeft;

};

Jeff Flinn
Josh McFarlane - 08 Jun 2005 23:55 GMT
Thanks, for some reason one of the other programs I was working on had
the std namespace messed up so I could use vectors without std::vector,
no clue why... just worked.

Got the vectors working in this program now! Thanks =)
Jeff F - 09 Jun 2005 12:47 GMT
> Thanks, for some reason one of the other programs I was working on had
> the std namespace messed up so I could use vectors without
> std::vector, no clue why... just worked.
>
> Got the vectors working in this program now! Thanks =)

All standard libbrary components(including anything referred to as stl) are
in namespace std. It is often best to explicitly qualify these. In some
cases you can bring the contents of any or all items from a namespace into
the current scope. This should be done with full knowledge of the
implications. A basic rule is to never do this in any file that can be
#included. A better solution often is to use typedefs.

For example in a function definition in a cpp file:

#include <vector>
#include <map>
#include <list>

typedef std::vector<int> tInts;

void somefnc()
{
   tInts lInts(10,-1);

   ...
}

void someotherfnc()
{
   using namespace std:

   tInts lInts(10,-1);

   list<int> lList;

   copy( lInts.begin(), lInts.end(), back_inserter(lList) );
}

Jeff Flinn

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.