Jump to content
  • Advertisement
Sign in to follow this  
bigjoe11a

Making a list

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

If you intended to correct an error in the post then please contact us.

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"
	
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
}

Share this post


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

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

Share this post


Link to post
Share on other sites
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


Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!