Solved

Vector of references?

Posted on 2008-10-09
2
618 Views
Last Modified: 2012-06-27
Can I use a vector (or any container) of references? Or must I use pointers?

If not, why not?

std::vector<Object&> vector_of_references;
0
Comment
Question by:nanderEire
  • 2
2 Comments
 
LVL 53

Accepted Solution

by:
Infinity08 earned 125 total points
ID: 22679161
>> Can I use a vector (or any container) of references?

No.


>> Or must I use pointers?

That is one option, yes.


>> If not, why not?

References always need to refer to an existing object. You cannot declare a reference without specifying which object it refers to. So, you cannot have a container of references.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 22679218
May I ask why you gave a B grade ? That usually means that something was missing in the answer and/or that something is still unclear. If that's the case, then do not hesitate to ask for clarification where needed.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Within a class, declare a function/method as static or not 16 132
Unresolved External Symbols 3 68
How to convert MFC::CString to UTF8 wchar_t* 10 137
What is sub-make ? 2 37
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now