0

Looking at some code my professor gave me and I don't understand what is happening. I am new to programming and completely lost.

vector <_Account*>*myvector = nullptr;

So I know he made a vector, and I know of an existing class called Account so is this a vector of pointers to an Account objects? and I don't know what the second asterisk does?

MWiesner
  • 8,868
  • 11
  • 36
  • 70
Franner
  • 88
  • 1
  • 5
  • 1
    Looking at this question/example, you might want to invest in a [good book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – Baum mit Augen Sep 29 '15 at 17:55
  • [The spiral rule](http://c-faq.com/decl/spiral.anderson.html) can be helpful for parsing complicated expressions. – user4581301 Sep 29 '15 at 18:32

3 Answers3

6

myvector is a pointer to vector (most likely std::vector + the bad practice using namespace std;) of pointers to _Account. No actual vector is created in this line, just a variable that can store the address of one.

_Account is an implementation reserved identifier btw, it must not be used.

Community
  • 1
  • 1
Baum mit Augen
  • 49,044
  • 25
  • 144
  • 182
0

This is a pointer to a vector of pointers to _Account (very badly named) class. To use the vector, it should either be allocated, or assigned to address of already existing vector of the same type. To use it's _Account elements, those elements in turn needs to be either allocated, or assigned to the addresses of existing _Account instances.

SergeyA
  • 61,605
  • 5
  • 78
  • 137
0

Lets break it down into two steps:

typedef vector<_Account*> objectvector;

objectvector *myvector = nullptr;

1) objectvector is a vector of pointers(of type _Account).

2) myvector is a pointer to type objectvector.

basav
  • 1,475
  • 12
  • 20