Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Probably a simple VECTOR question

Status
Not open for further replies.

BKQc

Programmer
Jul 26, 2002
118
CA
I'm really new to C++ and my problem is that I'm trying to store objects created from my own classe to some vectors.
My class name is Artist and I'm trying to enter it in a vector called oArtist.
The code I use is
Vector <Artist> oArtist;
and the error I get is:
&quot;Nom de type attendu&quot; (sorry, stuck with a french version. It's probably something like &quot;Type name expected&quot;)

Is it because I need to have some specific stuff in my object?

Thx for your help!
 
Not sure whether you have typos in your posting. vector is in lowercase and you have to tell the compiler it is from the std namespace. Something like the following should work. Remember that if you have pointers in your class, you should provide the appropriate copy constructor and assignment operator (operator =).

#include <vector>
using namespace std; // This is probably missing

class Bacteria
{
};

vector <Bacteria> culture;
 
What is the namespace used for?
 
Namespace is a unit for grouping classes and instances and limiting their scope.

For instance, if you have code from more than one source and there is a name clash, using namespaces can get you round this problem. Look up &quot;using Directive&quot; on MSDN.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top