Write a statement that declares and stores the elements of the following array into a vector object:
char vowels[5]={'a', 'e', 'i', 'o', 'u'};

I think this is what I need, but I want to verify this.

char vowels[5]={'a', 'e', 'i', 'o', 'u'};
vector<vowels> vowelsList (vowelsArray, vowelsArray +5);

Recommended Answers

All 2 Replies

No. The type between < and > in vector must be a data type, not the name of a variable. vowels is not a datatype.

use vector::assign
See this link. There is a similar example given.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.