Hey, er lige igang med et eller andet underligt program, men er støt på en fejl.. Kan ikke se hvad fejlen skulle være. Men den ligger i productsFunction..
Kode:
main.cpp
#include "includer.h"
#include "products.h"
#include "classes.h"
int main()
{
cout << "Welcome to my store!" << endl;
cout << "Please enter your name, or if administrator enter admin." << endl;
//Laver ny class
Persons persons;
//Pointer til classen Persons
persons.name = new char[80];
string Name = persons.name;
cin >> Name;
if(Name == "admin" || Name == "Admin")
{
cout << "New or browse?" << endl;
string answer;
cin >> answer;
if(answer == "1")
{
}
// ADMINISTRATOR!
}
else
{
system("CLS");
cout << "Welcome " << Name << endl;
}
}
products.h
#include "includer.h"
class Products {
public:
Products();
// Nyt produkt som skal skrives ind i vector
int newProduct(string name, vector<string> &vector);
// Mulighed for at søge vectoren igennem
int searchProduct(vector<string> &vector);
void browseProducts(vector<string> vector);
vector<string> vectorProducts;
};
productsFunction.cpp
#include "products.h"
#include "includer.h"
int Products::newProduct(string name, vector<string> &vector)
{
cout << "Enter the name of the new product: ";
getline(cin, name);
vector.push_back(name);
}
void Products::browseProducts(vector<string> vector)
{
system("CLS");
cout << "Browsing Products.." << endl;
Sleep(3000);
vector<string>::iterator iter;
for(iter = vector.begin(); iter != vector.end(), iter++)
{
cout << *iter << endl;
}
}
Log:
1>------ Build started: Project: PayProgram, Configuration: Debug Win32 ------
1>Compiling...
1>productsFunctions.cpp
1>f:\c++ programmer\c++ projekter\paything\payprogram\productsfunctions.cpp(17) : error C2275: 'std::string' : illegal use of this type as an expression
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\xstring(2210) : see declaration of 'std::string'
1>f:\c++ programmer\c++ projekter\paything\payprogram\productsfunctions.cpp(17) : error C2955: 'std::iterator' : use of class template requires template argument list
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\xutility(688) : see declaration of 'std::iterator'
1>f:\c++ programmer\c++ projekter\paything\payprogram\productsfunctions.cpp(17) : fatal error C1903: unable to recover from previous error(s); stopping compilation
1>Build log was saved at "file://f:\c++ programmer\c++ Projekter\PayThing\PayProgram\Debug\BuildLog.htm"
1>PayProgram - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Tak på forhånd
Indlæg senest redigeret d. 10.09.2009 16:10 af Bruger #14212