Public Group

Making a list

This topic is 3982 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I have a sample that lets me make a list of bank names. It just every time I add this to the top of my code I get 2 errors list<string> banks; 1) savings.cpp(11) : error C2143: syntax error : missing ';' before '<' 2) savings.cpp(11) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int The sample I got was from the C++ for dummies. Can any one tell me why this isn't working. Heres some of my code.
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <list>
#include <string>

#include "Savings.h"

list<string> banks; // Errors out here

void bankinfo()
{
std::string bank;
std::cout << "Input Bank Name : ";
std::cin bank;

banks.push_back(bank);

system("pause");

}

int main(int argc, char* pArgs[])
{
}


Share on other sites
it needs to be "std::list" instead of "list".

Alternatively, you could add "using namespace std;" after all of your #include statements.

Share on other sites
Quote:
 Original post by Hodgmanit needs to be "std::list" instead of "list".Alternatively, you could add "using namespace std;" after all of your #include statements.

Then let me ask you. I have a guy from your forums section thats helping me to under stand C++, and he told me that using "using namespace std;" on larger programs is not a good idea.

he said I'm better off using

std:: as its needed

Share on other sites
It may be a bad idea to use using namespace std; in a header, because the person using the header may not be aware that you're doing it. So use std:: in headers, but there is really nothing stopping you from using it in source files.

ok, Thanks

1. 1
2. 2
3. 3
Rutin
20
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 12
• Forum Statistics

• Total Topics
633655
• Total Posts
3013181
×