little_greg Posted October 19, 2010 Report Share Posted October 19, 2010 Объясните, пож, почему возникают ошибки и помогите исправить: "error: expected ';' before 'p'" "error: 'p' was not declared in this scope" "error: dependent-name 'std::vector::const_iterator' is parsed as a non-type, but instantiation yields a type" #ifndef ASSOC_H_#define ASSOC_H_#include <iostream>#include <string>#include <vector>#include <iterator>using std::vector;using std::string;using std::cout;template<class T>class Assoc{ private: struct Pair { T name; double val; Pair(T n = "", double v = 0):name(n),val(v){} }; vector<Pair> vec; public: Assoc(){} void print_all() const;};template<class T>void Assoc<T>::print_all() const{ for (vector<Pair>::const_iterator p = vec.begin(); p != vec.end(); p++) cout << p->name << ": " << p->val << '\n';}#endif Link to comment Share on other sites More sharing options...
Amsterdam Posted October 20, 2010 Report Share Posted October 20, 2010 Какая среда используется? В C++ Builder код работает нормально. Link to comment Share on other sites More sharing options...
little_greg Posted October 21, 2010 Author Report Share Posted October 21, 2010 Code::Blocks 10.05, DEV-C++ 4.9.9.2 Link to comment Share on other sites More sharing options...
Amsterdam Posted October 21, 2010 Report Share Posted October 21, 2010 На эту строчку поменяй соответствующую for (class vector<Pair>::const_iterator p = vec.begin(); p != vec.end(); p++) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now