Undeclared Identifier

Mar 11, 2012 at 4:54pm
Firstly, I'm using VC++: VS2010 Ultimate (build 10.0.40219.1 SP1)

Secondly, I'm having some issues with the compiler recognizing my objects: I say objects because both objects (a struct and class) in the program are not being recognized; I say compiler because of a lack of "squiggly lines" on the IDE. (In fact, my IDE recognizes both of them.)

I've attached a snippet below, many thanks for any insight in what I'm doing wrong.


Also, I apologize for the names; it's a class thing.

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
#include <iostream>;
#include <iomanip>;
#include <string>;
#include <stdlib.h>;

using namespace std;

int main (){
	JunkDrawer Razor;

	Razor.WorkLoop();

	return 0;
}

struct JunkDrawer{


	void DisplayDivider(string output){
	cout << setw(15) << output << setw(15)<< endl;
	}

	bool Question(){
		bool persistence;
		string love;

		cout  << setw(15) << "Continue?" << setw(15)<< endl;
		cout << "Y/N?  ";
		cin >> love;
		(love != "Y") ? (persistence = false) : (persistence = true);

		return persistence;
	}

	void WorkLoop(){
		bool foo = true;
		while (bool foo = true){
			JunkDrawer.DisplayDivider("Employee Information");
			Employee SuperAwesomeTeamWolfSquadron =  Employee.Employee();
			SuperAwesomeTeamWolfSquadron.setFirstName();
			SuperAwesomeTeamWolfSquadron.setLastName();
			SuperAwesomeTeamWolfSquadron.setGender();
			SuperAwesomeTeamWolfSquadron.setDependents();
			SuperAwesomeTeamWolfSquadron.setAnnualSalary();
			JunkDrawer.DisplayDivider("Employee Information");
			SuperAwesomeTeamWolfSquadron.displayEmployee();
			foo = JunkDrawer.Question();

		}
	}
};


TL;DR version: I can't compile sh!t, I've got some vague error codes, (Mostly C2065, C2143 and C2228.)but my IDE is giving a thumbs up.
Mar 11, 2012 at 4:55pm
TL;DR You have to declare or define things BEFORE you try to use them.
Mar 11, 2012 at 4:59pm
#include <iostream>;
There should not be a semicolon there.
Same with the other #include's.

Oh, and your definition of struct JunkDrawer needs to go above main().
(as Moschops was trying to say)
Last edited on Mar 11, 2012 at 5:01pm
Mar 11, 2012 at 5:14pm
No shit.

I'm not even going to talk about dignity. Thanks folks.
Topic archived. No new replies allowed.