bool function
Apr 26, 2013 at 5:01pm UTC
Hello.
I am now learning classes and vectors. To learn it better I tried to make small program to understand it better. After some time I managed to make a bool function in my code and see what would be, but the program doesn't work anyways I've tried. I don't really understand what should i do. Maybe I made a mistake in classes, function, or should I make a pointer or something? PLEASE HELP!
Here's the code ;)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#include <iostream>
#include <vector>
using namespace std;
class Vector {
int a, b;
public :
vector<int > VECT;
void vectorPrint();
void addNumber();
bool Continue();
};
bool Vector::Continue() {
char Cont;
cout << "Add more numbers?: (y/n)" << endl;
cin >> Cont;
if (Cont == 't' )
return true ;
else
return false ;
}
void Vector::addNumber() {
cout << "In witch place you want to add number to vector?: " << endl;
cin >> a;
cout << "What number do you want to add?: " << endl;
cin >> b;
}
void Vector::vectorPrint() {
addNumber();
VECT.push_back(1);
VECT.insert(VECT.begin() + a, b);
for (unsigned int v = 0; v < VECT.size(); v++) {
cout << VECT[v] << " " ;
}
cout << endl;
}
int main() {
while (Continue()) {
Vector print;
print.vectorPrint();
Continue();
}
}
Compiler errors:
(43): error C3861: 'Continue': identifier not found
(46): error C3861: 'Continue': identifier not found
PLEASE HELP ME IF YOU KNOW MY PROBLEM! THANKS!
Apr 26, 2013 at 5:10pm UTC
Continue is a method on your Vector class. You're calling it as if it were a global function.
Last edited on Apr 26, 2013 at 5:10pm UTC
Apr 26, 2013 at 5:14pm UTC
Thank you, now I understand ;)
Apr 26, 2013 at 5:17pm UTC
You're welcome :)
Topic archived. No new replies allowed.