deni01 2012. jan. 30. 22:55 | válasz | #233
köszönöm kl24h a gyors segítséget bemásolom a teljes programot én már tényleg halál ideges vagyok tõle nem régen kezdtem egy barátom segítetett ebben és egyszerûen nem találom a hibát, ez lenne az alap progi: #include <cstdlib> #include <iostream> #include <vector> //#include "verem.h" class verem{ public: verem(int meret=10); bool isempty(); bool isfull(); void push(int a); int pop(); int top(); enum Hiba{URES,TELE}; private: std::vector<int> v; int top_index; }; /*********************************************/ verem::verem(int meret): v(meret){ top_index = -1; } bool verem::isempty(){ return top_index == -1; } bool verem::isfull(){ return top_index == v.size()-1; } void verem::push(int a){ if(!isfull()){ ++top_index; v[top_index]=a; } else throw TELE; } int verem::pop(){ if(!isempty()){ --top_index; return v[top_index+1]; } else throw URES; } int verem::top(){ if(!isempty()) return v[top_index]; else throw URES; } using namespace std; int main() { verem a_stack; init(&a_stack); push(&a_stack, 1); cout << "Verem merete: " << count(&a_stack) << '\n'; cout << "verem értek: " << pop(&a_stack) << '\n'; cout << "verem ertek: " << pop(&a_stack) << '\n'; cout << "verem ertek: " << pop(&a_stack) << '\n'; final(&a_stack); system("PAUSE"); return EXIT_SUCCESS; } ez a verem.h tartalom: #include<vector> /* Verem tombos abrazolassal */ class verem{ public: verem(int meret=10); bool isempty(); bool isfull(); void push(int a); int pop(); int top(); enum Hiba{URES,TELE}; private: std::vector<int> v; int top_index; }; /*********************************************/ verem::verem(int meret): v(meret){ top_index = -1; } bool verem::isempty(){ return top_index == -1; } bool verem::isfull(){ return top_index == v.size()-1; } void verem::push(int a){ if(!isfull()){ ++top_index; v[top_index]=a; } else throw TELE; } int verem::pop(){ if(!isempty()){ --top_index; return v[top_index+1]; } else throw URES; } int verem::top(){ if(!isempty()) return v[top_index]; else throw URES; } ez pedig a vektor.h tartalma: #ifndef SS_Vector_H #define SS_Vector_H #include "common.h" class Vector : public Point { public: // Constructors same as Point class Vector() : Point() {}; Vector( int a) : Point(a) {}; Vector( double a) : Point(a) {}; Vector( int a, int b) : Point(a,b) {}; Vector( double a, double b) : Point(a,b) {}; Vector( int a, int b, int c) : Point(a,b,c) {}; Vector( double a, double b, double c) : Point(a,b,c) {}; Vector( int n, int a[]) : Point(n,a) {}; Vector( int n, double a[]) : Point(n,a) {}; ~Vector() {}; //---------------------------------------------------------- // IO streams and Comparisons: inherit from Point class //---------------------------------------------------------- // Vector Unary Operations Vector operator-(); // unary minus Vector operator~(); // unary 2D perp operator //---------------------------------------------------------- // Scalar Multiplication friend Vector operator*( int, Vector); friend Vector operator*( double, Vector); friend Vector operator*( Vector, int); friend Vector operator*( Vector, double); // Scalar Division friend Vector operator/( Vector, int); friend Vector operator/( Vector, double); //---------------------------------------------------------- // Vector Arithmetic Operations Vector operator+( Vector); // vector add Vector operator-( Vector); // vector subtract double operator*( Vector); // inner dot product double operator|( Vector); // 2D exterior perp product Vector operator^( Vector); // 3D exterior cross product Vector& operator*=( double); // vector scalar mult Vector& operator/=( double); // vector scalar div Vector& operator+=( Vector); // vector increment Vector& operator-=( Vector); // vector decrement Vector& operator^=( Vector); // 3D exterior cross product //---------------------------------------------------------- // Vector Properties double len() { // vector length return sqrt(x*x + y*y + z*z); } double len2() { // vector length squared (faster) return (x*x + y*y + z*z); } //---------------------------------------------------------- // Special Operations void normalize(); // convert vector to unit length friend Vector sum( int, int[], Vector[]); // vector sum friend Vector sum( int, double[], Vector[]); // vector sum }; #endif SS_Vector_H fordításnál semmilyen hibát nem jelez csak a hibakód azaz 1db és áááá megõrülök tõle... ha valakinek sikerül valahogy megoldania az kérem írjon hogy mit merre hogyan :) elõre is köszönöm