why does this error show up “error: expected initializer before '<' token const Item...
up vote
-2
down vote
favorite
this is a template stack class. the error
error: expected initializer before '<' token
const Item stack<Item>::size_type
occurs for all my functions.
template<class Item>
const Item stack<Item>::size_type
stack<Item>::CAPACITY;
template<class Item>
void stack<Item>::push(const Item &entry) {
assert(size() > CAPACITY);
data[used] = entry;
++used;
}
template<class Item>
void stack<Item>::pop() {
assert(!empty());
--used;
}
template<class Item>
Item stack<Item>::top() const {
assert(!empty());
return data[used - 1];
}
template<class Item>
void stack<Item>::print() {
std::cout << size() const << endl;
}
c++ c++11
add a comment |
up vote
-2
down vote
favorite
this is a template stack class. the error
error: expected initializer before '<' token
const Item stack<Item>::size_type
occurs for all my functions.
template<class Item>
const Item stack<Item>::size_type
stack<Item>::CAPACITY;
template<class Item>
void stack<Item>::push(const Item &entry) {
assert(size() > CAPACITY);
data[used] = entry;
++used;
}
template<class Item>
void stack<Item>::pop() {
assert(!empty());
--used;
}
template<class Item>
Item stack<Item>::top() const {
assert(!empty());
return data[used - 1];
}
template<class Item>
void stack<Item>::print() {
std::cout << size() const << endl;
}
c++ c++11
Missing headers, definitions, etc. Please post the Minimal, Complete, and Verifiable example that reproduces the compiler error.
– PaulMcKenzie
Nov 12 at 0:47
1
That line has a syntax error, it would also help if you explain what you think that line is trying to do
– M.M
Nov 12 at 1:02
Probably not your issue per se, but it seems odd thatstack<Item>::size_type
would be of typeItem
and not some integral type
– shay
Nov 12 at 1:03
const Item stack<Item>::size_type stack<Item>::CAPACITY;
should beconst stack<Item>::size_type stack<Item>::CAPACITY = SomeValue;
– Remy Lebeau
Nov 12 at 5:58
add a comment |
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
this is a template stack class. the error
error: expected initializer before '<' token
const Item stack<Item>::size_type
occurs for all my functions.
template<class Item>
const Item stack<Item>::size_type
stack<Item>::CAPACITY;
template<class Item>
void stack<Item>::push(const Item &entry) {
assert(size() > CAPACITY);
data[used] = entry;
++used;
}
template<class Item>
void stack<Item>::pop() {
assert(!empty());
--used;
}
template<class Item>
Item stack<Item>::top() const {
assert(!empty());
return data[used - 1];
}
template<class Item>
void stack<Item>::print() {
std::cout << size() const << endl;
}
c++ c++11
this is a template stack class. the error
error: expected initializer before '<' token
const Item stack<Item>::size_type
occurs for all my functions.
template<class Item>
const Item stack<Item>::size_type
stack<Item>::CAPACITY;
template<class Item>
void stack<Item>::push(const Item &entry) {
assert(size() > CAPACITY);
data[used] = entry;
++used;
}
template<class Item>
void stack<Item>::pop() {
assert(!empty());
--used;
}
template<class Item>
Item stack<Item>::top() const {
assert(!empty());
return data[used - 1];
}
template<class Item>
void stack<Item>::print() {
std::cout << size() const << endl;
}
c++ c++11
c++ c++11
edited Nov 12 at 0:57
O'Neil
3,32321125
3,32321125
asked Nov 12 at 0:25
John Snow
11
11
Missing headers, definitions, etc. Please post the Minimal, Complete, and Verifiable example that reproduces the compiler error.
– PaulMcKenzie
Nov 12 at 0:47
1
That line has a syntax error, it would also help if you explain what you think that line is trying to do
– M.M
Nov 12 at 1:02
Probably not your issue per se, but it seems odd thatstack<Item>::size_type
would be of typeItem
and not some integral type
– shay
Nov 12 at 1:03
const Item stack<Item>::size_type stack<Item>::CAPACITY;
should beconst stack<Item>::size_type stack<Item>::CAPACITY = SomeValue;
– Remy Lebeau
Nov 12 at 5:58
add a comment |
Missing headers, definitions, etc. Please post the Minimal, Complete, and Verifiable example that reproduces the compiler error.
– PaulMcKenzie
Nov 12 at 0:47
1
That line has a syntax error, it would also help if you explain what you think that line is trying to do
– M.M
Nov 12 at 1:02
Probably not your issue per se, but it seems odd thatstack<Item>::size_type
would be of typeItem
and not some integral type
– shay
Nov 12 at 1:03
const Item stack<Item>::size_type stack<Item>::CAPACITY;
should beconst stack<Item>::size_type stack<Item>::CAPACITY = SomeValue;
– Remy Lebeau
Nov 12 at 5:58
Missing headers, definitions, etc. Please post the Minimal, Complete, and Verifiable example that reproduces the compiler error.
– PaulMcKenzie
Nov 12 at 0:47
Missing headers, definitions, etc. Please post the Minimal, Complete, and Verifiable example that reproduces the compiler error.
– PaulMcKenzie
Nov 12 at 0:47
1
1
That line has a syntax error, it would also help if you explain what you think that line is trying to do
– M.M
Nov 12 at 1:02
That line has a syntax error, it would also help if you explain what you think that line is trying to do
– M.M
Nov 12 at 1:02
Probably not your issue per se, but it seems odd that
stack<Item>::size_type
would be of type Item
and not some integral type– shay
Nov 12 at 1:03
Probably not your issue per se, but it seems odd that
stack<Item>::size_type
would be of type Item
and not some integral type– shay
Nov 12 at 1:03
const Item stack<Item>::size_type stack<Item>::CAPACITY;
should be const stack<Item>::size_type stack<Item>::CAPACITY = SomeValue;
– Remy Lebeau
Nov 12 at 5:58
const Item stack<Item>::size_type stack<Item>::CAPACITY;
should be const stack<Item>::size_type stack<Item>::CAPACITY = SomeValue;
– Remy Lebeau
Nov 12 at 5:58
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254597%2fwhy-does-this-error-show-up-error-expected-initializer-before-token-const%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Missing headers, definitions, etc. Please post the Minimal, Complete, and Verifiable example that reproduces the compiler error.
– PaulMcKenzie
Nov 12 at 0:47
1
That line has a syntax error, it would also help if you explain what you think that line is trying to do
– M.M
Nov 12 at 1:02
Probably not your issue per se, but it seems odd that
stack<Item>::size_type
would be of typeItem
and not some integral type– shay
Nov 12 at 1:03
const Item stack<Item>::size_type stack<Item>::CAPACITY;
should beconst stack<Item>::size_type stack<Item>::CAPACITY = SomeValue;
– Remy Lebeau
Nov 12 at 5:58