Oh. I have Recordsbook there because when I learned of classes, at the end of a class the object name of it would be there. To call to Menu in it like I am, I'd call Recordsbook.Menu(). That is what I learned, anyway.
I understand. I will experiment with that in future programs, and try to get accustomed to not needing everything in classes.
Would I write it as vector<string> Record book(10); then?
Also, now it is also returning an error 'error: 'book' was not declared in this scope', but only for the lines book[I].setRecNum(r); and book[I].getRecNum(); and also an error of 'error: expected ';' at end of member declaration' and 'error: 'book' does not name a type'
I go to the line where the errors are and that's all it says. When I compile it this is everything it prints out. There is no other information about the errors except what I already put.
I just keep getting more errors I don't know how to fix when I'm trying to fix one. I really want to just give up on it because of it. :/
cd 'C:\Users\Mouse\Documents\NetBeansProjects\CppApplication_1'
C:\cygwin64\bin\make.exe -f Makefile CONF=Debug
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/cygdrive/c/Users/Mouse/Documents/NetBeansProjects/CppApplication_1'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin-Windows/cppapplication_1.exe
make[2]: Entering directory '/cygdrive/c/Users/Mouse/Documents/NetBeansProjects/CppApplication_1'
mkdir -p build/Debug/Cygwin-Windows
rm -f "build/Debug/Cygwin-Windows/main.o.d"
g++ -c -g -MMD -MP -MF "build/Debug/Cygwin-Windows/main.o.d" -o build/Debug/Cygwin-Windows/main.o main.cpp
main.cpp:10:20: error: expected ';' at end of member declaration
vector<string> Record book;
^~~~~~
main.cpp:10:27: error: 'book' does not name a type
vector<string> Record book;
^~~~
main.cpp: In member function 'void Recordsbook::InputInfo()':
main.cpp:40:17: error: 'book' was not declared in this scope
book[i].setRecNum(r);
^~~~
main.cpp: In member function 'void Recordsbook::Display()':
main.cpp:66:23: error: 'book' was not declared in this scope
cout<<book[i].getRecNum();
^~~~
make[2]: *** [nbproject/Makefile-Debug.mk:74: build/Debug/Cygwin-Windows/main.o] Error 1
make[2]: Leaving directory '/cygdrive/c/Users/Mouse/Documents/NetBeansProjects/CppApplication_1'
make[1]: *** [nbproject/Makefile-Debug.mk:60: .build-conf] Error 2
make[1]: Leaving directory '/cygdrive/c/Users/Mouse/Documents/NetBeansProjects/CppApplication_1'
make: *** [nbproject/Makefile-impl.mk:40: .build-impl] Error 2
BUILD FAILED (exit value 2, total time: 3s)
and my code even though it didn't change. (main.cpp)
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include "Record.h"
using namespace std;
class Recordsbook
{
vector<string> Record book;
public:
void Menu()
{
int choice = 0;
cout << "---Main Menu---\n";
cout << "1. Input information\n";
cout << "2. Display records\n";
cout << "3. Exit\n";
cin >> choice;
switch (choice)
{
case 1:
InputInfo();
break;
case 2:
Display();
break;
case 3:
Exit();
break;
}
}
void InputInfo()
{
for(int i = 0; i<10; i++)
{
cout << "What is the record number? ";
string r = "";
cin >> r;
book[i].setRecNum(r);
cout << "What is the first name? ";
string f = "";
cin >> f;
book[i].setFirstName(f);
cout << "What is the last name? ";
string l = "";
cin >> l;
book[i].setLastName(l);
cout << "What is the age? ";
string a = "";
cin >> a;
book[i].setAge(a);
cout << "What is the telephone number? ";
string t = "";
cin >> t;
book[i].setTelephone(t);
}
Menu();
};
void Display()
{
int i = 0;
for(i=0; i<10; i++)
{
cout<<"Record number: ";
cout<<book[i].getRecNum();
cout<<"\n";
cout<< "First name: ";
cout<<book[i].getFirstName();
cout<<"\n";
cout<< "Last name: ";
cout<<book[i].getLastName();
cout<<"\n";
cout<< "Age: ";
cout<<book[i].getAge();
cout<<"\n";
cout<< "Telephone number: ";
cout<<book[i].getTelephone();
cout<<"\n";
cout<<"\n";
}
Menu();
};
void Exit()
{
cout << "Closing...";
};
} Recordsbook;
int main()
{
Recordsbook.Menu();
}
|