#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <list>
#include <string>
#include "Savings.h"
bool loadit;
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[])
{
// my menu
}
Making a list
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.
it needs to be "std::list" instead of "list".
Alternatively, you could add "using namespace std;" after all of your #include statements.
Alternatively, you could add "using namespace std;" after all of your #include statements.
Quote:Original post by Hodgman
it 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
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement